public CompressionWebSocketBenchmarks() { _singleWebSocket = new CompressionWebSocket(Stream.Null, null, KEEP_ALIVE_INTERVAL, RECEIVE_BUFFER_SIZE); _multipleWebSockets = new List <CompressionWebSocket>(); for (int i = 0; i < MULTIPLE_CLIENTS_COUNT; i++) { _multipleWebSockets.Add(new CompressionWebSocket(Stream.Null, null, KEEP_ALIVE_INTERVAL, RECEIVE_BUFFER_SIZE)); } }
private static Task SendAsync(WebSocket webSocket, ArraySegment <byte> messageSegment, WebSocketMessageType messageType, bool compressed, bool endOfMessage, CancellationToken cancellationToken) { if (compressed) { CompressionWebSocket compressionWebSocket = (webSocket as CompressionWebSocket) ?? throw new InvalidOperationException($"In order to send compressed message the used {nameof(WebSocket)} implementation must be {nameof(CompressionWebSocket)}."); return(compressionWebSocket.SendAsync(messageSegment, messageType, true, endOfMessage, cancellationToken)); } else { return(webSocket.SendAsync(messageSegment, messageType, endOfMessage, cancellationToken)); } }