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(); }
public async Task SendTo(SocketClient.SocketClient client, object msg) { var msgstr = JsonConvert.SerializeObject(msg); await SendTo(client, msgstr); }
/// <summary> /// 发送给某人 /// </summary> /// <param name="name"></param> /// <param name="msg"></param> public async Task SendTo(SocketClient.SocketClient client, string msg) { await client.SendMsg(msg); }