示例#1
0
        private async Task SendWebSocketAsync(WebSocket webSocket, WebSocketMessage msg, CancellationToken cancellationToken = default)
        {
            var buffer = Encoding.ASCII.GetBytes(msg.GetJson());
            await webSocket.SendAsync(new ArraySegment <byte>(buffer), WebSocketMessageType.Text, true, cancellationToken);

            if (logger != null)
            {
                await logger.LogDebug($"Sent message {msg.Method}");
            }
        }