/// <summary> /// Connects this CoreRemoting client instance to the configured CoreRemoting server. /// </summary> /// <exception cref="RemotingException">Thrown, if no channel is configured.</exception> /// <exception cref="NetworkException">Thrown, if handshake with server failed.</exception> public void Connect() { if (_channel == null) { throw new RemotingException("No client channel configured."); } _channel.Connect(); if (_channel.RawMessageTransport.LastException != null) { throw _channel.RawMessageTransport.LastException; } if (_config.ConnectionTimeout == 0) { _handshakeCompletedWaitHandle.Wait(); } else { _handshakeCompletedWaitHandle.Wait(_config.ConnectionTimeout * 1000); } if (!_handshakeCompletedWaitHandle.IsSet) { throw new NetworkException("Handshake with server failed."); } else { Authenticate(); } StartKeepSessionAliveTimer(); }