• 大小: 1.54MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-08-31
  • 语言: 其他
  • 标签: websocket  

资源简介

socket服务端采用SuperSocket搭建,客户端与服务端进行连接及向服务端发送消息,服务端使用业务向客户端发送消息进行通信

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WebSocket4Net;
using System.Threading;

namespace Client
{
    public partial class CFrmMain : Form
    {
        WebSocket websocket ;
            
        public CFrmMain()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender EventArgs e)
        {
            
        }

        private void websocket_MessageReceived(object sender MessageReceivedEventArgs e)
        {            
            this.listBox1.Invoke(new EventHandler(ShowMessage) e.Message);

        }

        private void ShowMessage(object sender EventArgs e)
        {           
            this.listBox1.Items.Add(sender.ToString());
        }

        private void websocket_Closed(object sender EventArgs e)
        {
            websocket.Send(“一个客户端 下线“);
        }

         void websocket_Opened(object sender EventArgs e)
        {
            websocket.Send(“一个客户端 上线“);            
        }

         private void button1_Click(object sender EventArgs e)
         {
             websocket = new WebSocket(“ws://“ + textBox1.Text + “:“ + textBox2.Text);
             websocket.Opened += websocket_Opened;
             websocket.Closed += websocket_Closed;
             websocket.MessageReceived += websocket_MessageReceived;
             websocket.Open();
         }

         private void button2_Click(object sender EventArgs e)
         {
             websocket.Send(textBox1.Text + “:“ + textBox2.Text + “发送:“ + textBox3.Text);
         }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     29696  2018-10-09 08:42  superwebsocket\.vs\SuperSocket_vs2013\v15\.suo

     文件          0  2018-10-09 08:38  superwebsocket\.vs\SuperSocket_vs2013\v15\Server\sqlite3\db.lock

     文件       4096  2018-10-09 08:38  superwebsocket\.vs\SuperSocket_vs2013\v15\Server\sqlite3\storage.ide

     文件      32768  2018-10-09 08:42  superwebsocket\.vs\SuperSocket_vs2013\v15\Server\sqlite3\storage.ide-shm

     文件     733392  2018-10-09 08:38  superwebsocket\.vs\SuperSocket_vs2013\v15\Server\sqlite3\storage.ide-wal

     文件        134  2015-01-05 08:34  superwebsocket\Client\app.config

     文件      10240  2018-10-09 08:39  superwebsocket\Client\bin\Debug\Client.exe

     文件        134  2015-01-05 08:34  superwebsocket\Client\bin\Debug\Client.exe.config

     文件      22016  2018-10-09 08:39  superwebsocket\Client\bin\Debug\Client.pdb

     文件      22704  2015-01-05 09:58  superwebsocket\Client\bin\Debug\Client.vshost.exe

     文件        134  2015-01-05 08:34  superwebsocket\Client\bin\Debug\Client.vshost.exe.config

     文件     590848  2015-01-04 21:08  superwebsocket\Client\bin\Debug\WebSocket4Net.dll

     文件       1763  2015-01-06 21:26  superwebsocket\Client\CFrmMain.cs

     文件       5805  2015-01-06 21:26  superwebsocket\Client\CFrmMain.Designer.cs

     文件       5817  2015-01-06 21:26  superwebsocket\Client\CFrmMain.resx

     文件       3997  2015-01-05 09:38  superwebsocket\Client\Client.csproj

     文件        443  2015-01-04 21:32  superwebsocket\Client\Form1.cs

     文件       1474  2015-01-04 21:32  superwebsocket\Client\Form1.Designer.cs

     文件       5817  2015-01-04 21:32  superwebsocket\Client\Form1.resx

     文件        180  2018-10-09 08:39  superwebsocket\Client\obj\Debug\Client.CFrmMain.resources

     文件          0  2018-10-09 08:39  superwebsocket\Client\obj\Debug\Client.csproj.CopyComplete

     文件         42  2018-10-09 08:38  superwebsocket\Client\obj\Debug\Client.csproj.CoreCompileInputs.cache

     文件       1534  2018-10-09 08:39  superwebsocket\Client\obj\Debug\Client.csproj.FileListAbsolute.txt

     文件        850  2015-01-06 21:34  superwebsocket\Client\obj\Debug\Client.csproj.GenerateResource.Cache

     文件      19795  2018-10-09 08:38  superwebsocket\Client\obj\Debug\Client.csprojAssemblyReference.cache

     文件       6415  2015-01-06 21:34  superwebsocket\Client\obj\Debug\Client.csprojResolveAssemblyReference.cache

     文件      10240  2018-10-09 08:39  superwebsocket\Client\obj\Debug\Client.exe

     文件        180  2015-01-04 22:09  superwebsocket\Client\obj\Debug\Client.Form1.resources

     文件      22016  2018-10-09 08:39  superwebsocket\Client\obj\Debug\Client.pdb

     文件        180  2018-10-09 08:39  superwebsocket\Client\obj\Debug\Client.Properties.Resources.resources

............此处省略81个文件信息

评论

共有 条评论