/// <summary> /// Web socket client. /// </summary> /// <param name="uri">The resource to connect to.</param> public WebSocketClient(Uri uri) { _client = new Nequeo.Net.WebSockets.WebSocketClient(uri); _client.SentAsyncSignal = _sentAsync; _client.ReceivedAsyncSignal = _receiveAsync; _client.OnConnected += _client_OnConnected; _client.OnDisconnected += _client_OnDisconnected; }
/// <summary> /// Web socket client. /// </summary> /// <param name="host">The remote host.</param> /// <param name="useSslConnection">Use a secure connection.</param> /// <param name="path">The remote host path.</param> public WebSocketClient(string host, bool useSslConnection = false, string path = "/") { _client = new Nequeo.Net.WebSockets.WebSocketClient(host, useSslConnection, path); _client.SentAsyncSignal = _sentAsync; _client.ReceivedAsyncSignal = _receiveAsync; _client.OnConnected += _client_OnConnected; _client.OnDisconnected += _client_OnDisconnected; }
/// <summary> /// Dispose(bool disposing) executes in two distinct scenarios. /// If disposing equals true, the method has been called directly /// or indirectly by a user's code. Managed and unmanaged resources /// can be disposed. /// If disposing equals false, the method has been called by the /// runtime from inside the finalizer and you should not reference /// other objects. Only unmanaged resources can be disposed. /// </summary> protected virtual void Dispose(bool disposing) { // Check to see if Dispose has already been called. if (!this._disposed) { // Note disposing has been done. _disposed = true; // If disposing equals true, dispose all managed // and unmanaged resources. if (disposing) { // Dispose managed resources. if (_client != null) { _client.Dispose(); } if (_sentAsync != null) { _sentAsync.Dispose(); } if (_receiveAsync != null) { _receiveAsync.Dispose(); } } // Call the appropriate methods to clean up // unmanaged resources here. _client = null; _sentAsync = null; _receiveAsync = null; _syncSent = null; _syncReceive = null; } }