/// <summary> /// Use this function in order to connect and authenticate. /// </summary> /// <param name="key">Your API key.</param> public async Task Connect(string key, bool useTls, Action <BaseMessage> received) { this.Client = new ClientWebSocket(); Uri url; if (useTls) { url = new Uri($"wss://{RemoteEndPoint.ToString()}"); } else { url = new Uri($"ws://{RemoteEndPoint.ToString()}"); } await Client.ConnectAsync(url, CancellationToken.None).ConfigureAwait(false); this.Transport = new BlackTeaTransport(Client, key, received); if (await Transport.Authenticate().ConfigureAwait(false)) { Connected = true; } else { throw new InvalidCredentialException("Login rejected."); } }