Gwupe.Cloud.Communication.CoupledConnection.Connect C# (CSharp) Method

Connect() public method

public Connect ( ) : void
return void
        public void Connect()
        {
            _messageHandler = new CoupledWebSocketMessageHandler(this);
            _connection = new WebSocketClientSSLConnection(_cert, _messageHandler);
            _connection.ConnectionClose += _messageHandler.OnClose;
            _connection.ConnectionClose += delegate { OnDisconnected(); };
            _connection.ConnectionOpen += _messageHandler.OnOpen;
            _connection.ConnectionOpen += delegate { OnConnected(); };
            _connection.ConnectionReadFull += ProcessStream;
            try
            {
                if (!_connection.Start(_uri.Host, _uri.Port.ToString(), _uri.PathAndQuery, true, "", "message"))
                {
                    throw new IOException("Unknown error connecting to " + _uri);
                }
                _connection.SendText(_uniqueId);
            }
            catch (Exception e)
            {
                Logger.Error("Failed to connect to server [" + _uri + "] : " + e.Message);
                throw new IOException("Failed to connect to server [" + _uri + "] : " + e.Message, e);
            }
        }