public override async Task ConnectAsync() { await base.ConnectAsync(); if (_webSocketTransport != null) { _webSocketTransport.OnTextReceived -= OnTextReceived; _webSocketTransport.OnBinaryReceived -= OnBinaryReceived; _webSocketTransport.OnAborted -= OnAborted; _webSocketTransport.Dispose(); } Uri uri = UriConverter.GetServerUri(true, ServerUri, EIO, Options.Path, Options.Query); _clientWebSocket = ClientWebSocketProvider(); if (Options.ExtraHeaders != null) { foreach (var item in Options.ExtraHeaders) { _clientWebSocket.SetRequestHeader(item.Key, item.Value); } } _webSocketTransport = new WebSocketTransport(_clientWebSocket, EIO) { ConnectionTimeout = Options.ConnectionTimeout }; _webSocketTransport.OnTextReceived = OnTextReceived; _webSocketTransport.OnBinaryReceived = OnBinaryReceived; _webSocketTransport.OnAborted = OnAborted; Debug.WriteLine($"[Websocket] Connecting"); await _webSocketTransport.ConnectAsync(uri).ConfigureAwait(false); Debug.WriteLine($"[Websocket] Connected"); }
public override void Dispose() { if (_Transport != null) { _Transport.Dispose(); } }
public void Dispose() { if (_Transport != null) { _Transport.Dispose(); } }
public void CloseConnection(string connectionId, bool keepAlive) { WebSocketTransport transport = null; if (keepAlive) { if (Connections.TryGetValue(connectionId, out transport)) { transport.Dispose(); } } else { if (Connections.TryRemove(connectionId, out transport)) { transport.Dispose(); } } }
public async Task WebSocketTransport_SetsState() { var sock = new FauxSock(); sock.RealState = WebSocketState.Open; var transport = new WebSocketTransport(sock); transport.Close(); transport.Dispose(); Assert.Equal(WebSocketState.Closed, sock.RealState); }
public async Task WebSocketTransport_Connects() { var sock = new FauxSock(); sock.RealState = WebSocketState.Open; var transport = new WebSocketTransport(sock); Assert.True(transport.IsConnected); transport.Close(); transport.Dispose(); }
public virtual void Dispose() { _server.Dispose(); _transport.Dispose(); }