示例#1
0
        public override async void Dispose()
        {
            Working = false;
            await SendMsg(new MessageModel { IsDisConnected = true });

            foreach (var clientSocket in ClientSockets)
            {
                clientSocket.Dispose();
            }
            ClientSockets.Clear();
            ClientSockets = null;

            Listener.ConnectionReceived -= OnConnection;
            Listener?.CancelIOAsync();
            Listener.Dispose();
            Listener = null;
        }
示例#2
0
        public void Stop()
        {
            IsRunning = false;
            //serverSocket.Shutdown(SocketShutdown.Both);


            foreach (KeyValuePair <EndPoint, TCPConnection> kvp in ClientSockets)
            {
                kvp.Value.Socket.Close();
            }


            serverSocket.Close();
            ClientSockets.Clear();

            OnStop?.Invoke();
        }
 public void Start()
 {
     ClientSockets.Clear();
     DeviceIds.Clear();
     _wsServer?.Start();
 }