/// <summary> /// Send a byte array message to the client. /// </summary> /// <param name="ByteArray">The message to send to the client.</param> public async Task SendBytes(byte[] ByteArray) { var outBuffer = new ArraySegment <byte>(ByteArray); SendBuffer.Add(outBuffer); if (SendBuffer.Count > 1) { return; } while (SendBuffer.Count > 0) { var segment = SendBuffer[0]; await ClientSocket.SendAsync(segment, WebSocketMessageType.Text, true, CancellationToken.None); SendBuffer.Remove(segment); } }