Esempio n. 1
0
        public async Task AddClient(string ip, int port, string sessionId, WebSocket webSocket, HttpContext context)
        {
            var client = new SocketClient.SocketClient()
            {
                Ip        = ip,
                Port      = port,
                SessionId = sessionId,
                Socket    = webSocket,
                Context   = context
            };

            SocketClientMgr.Instance.AddClient(client);
            client.OnReceive += Client_OnReceive;
            client.OnConnect += Client_OnConnect;
            client.OnClose   += Client_OnClose;
            await client.StartReceive();
        }
Esempio n. 2
0
        public async Task SendTo(SocketClient.SocketClient client, object msg)
        {
            var msgstr = JsonConvert.SerializeObject(msg);

            await SendTo(client, msgstr);
        }
Esempio n. 3
0
 /// <summary>
 /// 发送给某人
 /// </summary>
 /// <param name="name"></param>
 /// <param name="msg"></param>
 public async Task SendTo(SocketClient.SocketClient client, string msg)
 {
     await client.SendMsg(msg);
 }