/// <summary> /// Удаление подключения /// </summary> public void Remove(string guid) { ETLSocket socket = null; if (sockets.ContainsKey(guid)) { sockets.TryRemove(guid, out socket); } socket?.Close(); }
/// <summary> /// Добавление нового подключения /// </summary> public ETLSocket Add(WebSocket socket) { ETLSocket etlSocket = new ETLSocket(socket); etlSocket.OnReceive += async(s, args) => await Invoke(args.Data); etlSocket.OnClose += (s, args) => { Remove(((ETLSocket)s).GUID); }; sockets.TryAdd(etlSocket.GUID, etlSocket); return(etlSocket); }