Exemplo n.º 1
0
 public void Disconnect()
 {
     if (_webSocketClient != null && _webSocketClient.IsAlive)
     {
         _webSocketClient.Close();
     }
 }
Exemplo n.º 2
0
 public async Task Close()
 {
     if (_webSocketClient != null && _webSocketClient.IsAlive)
     {
         await _webSocketClient.Close();
     }
 }
Exemplo n.º 3
0
 public override void DisconnectLocalClient()
 {
     if (client != null)
     {
         client.Close();
     }
 }
        public void Should_raise_closed_event_on_socket_instance_when_closing_through_handler()
        {
            IWebSocketClient client = null;

            _handler.WhenForAnyArgs(h => h.OnOpen(null)).Do(ci => client = ci.Arg <IWebSocketClient>());
            _handler.When(h => h.OnMessage("close")).Do(_ => client.Close());

            var closeListener = Substitute.For <EventHandler>();

            _browser.OpenWebSocket("/ws", socket =>
            {
                socket.Opened += (sender, args) => socket.Send("close");
                socket.Closed += closeListener;
            });
            closeListener.ReceivedWithAnyArgs(1)(null, null);
        }
Exemplo n.º 5
0
        private void Close()
        {
            Log.Info($"Closing connection: {ID}");

            _objKeepAliveMonitor.TimeOut      -= _objKeepAliveMonitor_TimeOut;
            _objKeepAliveMonitor.UnResponsive -= _objKeepAliveMonitor_UnResponsive;

            _objWebSocketClient.OnOpen    -= Connection_OnOpen;
            _objWebSocketClient.OnClose   -= Connection_OnClose;
            _objWebSocketClient.OnError   -= Connection_OnError;
            _objWebSocketClient.OnMessage -= Connection_OnMessage;

            if (
                _objWebSocketClient.ReadyState != WebSocketState.Closing &&
                _objWebSocketClient.ReadyState != WebSocketState.Closed
                )
            {
                _objWebSocketClient.Close();
            }
            _objKeepAliveMonitor.Stop();
        }
Exemplo n.º 6
0
 public override void DisconnectLocalClient()
 {
     WebSocketClient.Close();
 }