internal WebSocketConnectionRfc6455(Stream clientStream, WebSocketListenerOptions options) { Guard.ParameterCannotBeNull(clientStream, "clientStream"); Guard.ParameterCannotBeNull(options, "options"); _writeSemaphore = new SemaphoreSlim(1); _options = options; _clientStream = clientStream; if (options.BufferManager != null) _buffer = options.BufferManager.TakeBuffer(14 + 125 + 125 + 8 + 10 + _options.SendBufferSize + 4 + 2); else _buffer = new Byte[14 + 125 + 125 + 8 + 10 + _options.SendBufferSize + 4 + 2]; _headerBuffer = new ArraySegment<Byte>(_buffer, 0, 14); _controlBuffer = new ArraySegment<Byte>(_buffer, 14, 125); _pongBuffer = new ArraySegment<Byte>(_buffer, 14 + 125, 125); _pingBuffer = new ArraySegment<Byte>(_buffer, 14 + 125 + 125, 8); SendBuffer = new ArraySegment<Byte>(_buffer, 14 + 125 + 125 + 8 + 10, _options.SendBufferSize); _keyBuffer = new ArraySegment<Byte>(_buffer, 14 + 125 + 125 + 8 + 10 + _options.SendBufferSize, 4); _closeBuffer = new ArraySegment<Byte>(_buffer, 14 + 125 + 125 + 8 + 10 + _options.SendBufferSize + 4, 2); switch (options.PingMode) { case PingModes.BandwidthSaving: _ping = new BandwidthSavingPing(this, _options.PingTimeout, _pingBuffer); break; case PingModes.LatencyControl: default: _ping = new LatencyControlPing(this, _options.PingTimeout, _pingBuffer); break; } }
internal WebSocketConnectionRfc6455(Stream clientStream, WebSocketListenerOptions options) { if (clientStream == null) { throw new ArgumentNullException("clientStream"); } if (options == null) { throw new ArgumentNullException("options"); } _writeSemaphore = new SemaphoreSlim(1); _options = options; _clientStream = clientStream; if (options.BufferManager != null) { _buffer = options.BufferManager.TakeBuffer(14 + 125 + 125 + 8 + 10 + _options.SendBufferSize + 4 + 2); } else { _buffer = new Byte[14 + 125 + 125 + 8 + 10 + _options.SendBufferSize + 4 + 2]; } _headerBuffer = new ArraySegment <Byte>(_buffer, 0, 14); _controlBuffer = new ArraySegment <Byte>(_buffer, 14, 125); _pongBuffer = new ArraySegment <Byte>(_buffer, 14 + 125, 125); _pingBuffer = new ArraySegment <Byte>(_buffer, 14 + 125 + 125, 8); SendBuffer = new ArraySegment <Byte>(_buffer, 14 + 125 + 125 + 8 + 10, _options.SendBufferSize); _keyBuffer = new ArraySegment <Byte>(_buffer, 14 + 125 + 125 + 8 + 10 + _options.SendBufferSize, 4); _closeBuffer = new ArraySegment <Byte>(_buffer, 14 + 125 + 125 + 8 + 10 + _options.SendBufferSize + 4, 2); switch (options.PingMode) { case PingModes.BandwidthSaving: _ping = new BandwidthSavingPing(this, _options.PingTimeout, _pingBuffer); break; case PingModes.LatencyControl: default: _ping = new LatencyControlPing(this, _options.PingTimeout, _pingBuffer); break; } }