/// <summary> /// Initializes a new instance of the <see cref="MsWebSocketTransport"/> class. /// </summary> /// <param name="parameters">Transport parameters.</param> /// <param name="socketOptions">Additional websocket options. See <see cref="MsWebSocketOptions"/>.</param> protected MsWebSocketTransport(TransportParams parameters, MsWebSocketOptions socketOptions) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters), "Null parameters are not allowed"); } _socketOptions = socketOptions ?? new MsWebSocketOptions(); BinaryProtocol = parameters.UseBinaryProtocol; WebSocketUri = parameters.GetUri(); Logger = parameters.Logger ?? DefaultLogger.LoggerInstance; }
/// <summary> /// Initializes a new instance of the <see cref="MsWebSocketConnection"/> class. /// </summary> /// <param name="uri">Uri used for the websocket connection.</param> /// <param name="socketOptions">additional socket options.</param> public MsWebSocketConnection(Uri uri, MsWebSocketOptions socketOptions) { _uri = uri; ClientWebSocket = new ClientWebSocket(); if (socketOptions.SendBufferInBytes.HasValue || socketOptions.ReceiveBufferInBytes.HasValue) { var receiveBuffer = socketOptions.ReceiveBufferInBytes ?? (8 * 1024); var sendBuffer = socketOptions.SendBufferInBytes ?? (8 * 1024); receiveBuffer = Math.Min(receiveBuffer, MaxAllowedBufferSize); sendBuffer = Math.Min(sendBuffer, MaxAllowedBufferSize); if (Logger.IsDebug) { Logger.Debug($"Setting socket buffers to: Receive: {receiveBuffer}. Send: {sendBuffer}"); } ClientWebSocket.Options.SetBuffer(receiveBuffer, sendBuffer); } }
/// <summary> /// Initializes a new instance of the <see cref="TransportFactory"/> class. /// </summary> /// <param name="socketOptions">Additional Websocket options. <see cref="MsWebSocketOptions"/>.</param> public TransportFactory(MsWebSocketOptions socketOptions) { SocketOptions = socketOptions; }
/// <summary> /// Initializes a new instance of the <see cref="TransportFactory"/> class. /// </summary> public TransportFactory() { SocketOptions = new MsWebSocketOptions(); }