private async Task ConnectWebSocketAsync() { webSocket = new ClientWebSocket(); webSocket.Options.SetRequestHeader("Authorization", config.Authorization); webSocket.Options.SetRequestHeader("Num-Shards", config.TotalShards.ToString()); webSocket.Options.SetRequestHeader("User-Id", manager.GetDiscordClient().CurrentUser.Id.ToString()); Console.WriteLine(new LogMessage(LogSeverity.Info, "Lavalink", "Connecting to Lavalink node")); await webSocket.ConnectAsync(hostUri, CancellationToken.None); Connected = true; Console.WriteLine(new LogMessage(LogSeverity.Info, "Lavalink", "Connected to Lavalink node")); while (webSocket.State == WebSocketState.Open) { string jsonString = await ReceiveAsync(webSocket); JObject json = JObject.Parse(jsonString); OnReceive?.Invoke(json).ConfigureAwait(false); } }
private async Task ConnectWebSocketAsync() { webSocket = new ClientWebSocket(); webSocket.Options.SetRequestHeader("Authorization", config.Authorization); webSocket.Options.SetRequestHeader("Num-Shards", config.TotalShards.ToString()); webSocket.Options.SetRequestHeader("User-Id", manager.GetDiscordClient().CurrentUser.Id.ToString()); manager.logger.Log($"Connecting to Lavalink node at {GetHostUri()}", LogSeverity.Info); await webSocket.ConnectAsync(hostUri, CancellationToken.None); Connected = true; manager.logger.Log($"Connected to Lavalink node", LogSeverity.Info); while (webSocket.State == WebSocketState.Open) { string jsonString = await ReceiveAsync(webSocket); JObject json = JObject.Parse(jsonString); OnReceive?.InvokeAsync(json); } }