private static WebSocketClientProtocolConfig CheckNotNull(WebSocketClientProtocolConfig clientConfig) { if (clientConfig is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.clientConfig); } return(clientConfig); }
/// <summary>Base constructor</summary> /// <param name="handshaker">The <see cref="WebSocketClientHandshaker"/> which will be used to issue the handshake once the connection /// was established to the remote peer.</param> /// <param name="handleCloseFrames"><c>true</c> if close frames should not be forwarded and just close the channel</param> /// <param name="dropPongFrames"><c>true</c> if pong frames should not be forwarded</param> /// <param name="handshakeTimeoutMillis">Handshake timeout in mills, when handshake timeout, will trigger user /// event <see cref="ClientHandshakeStateEvent.HandshakeTimeout"/></param> /// <param name="enableUtf8Validator"></param> public WebSocketClientProtocolHandler(WebSocketClientHandshaker handshaker, bool handleCloseFrames, bool dropPongFrames, long handshakeTimeoutMillis, bool enableUtf8Validator = true) : base(dropPongFrames) { if (handshakeTimeoutMillis <= 0L) { ThrowHelper.ThrowArgumentException_Positive(handshakeTimeoutMillis, ExceptionArgument.handshakeTimeoutMillis); } _handshaker = handshaker; _clientConfig = WebSocketClientProtocolConfig.NewBuilder() .HandleCloseFrames(handleCloseFrames) .HandshakeTimeoutMillis(handshakeTimeoutMillis) .WithUTF8Validator(enableUtf8Validator) .Build(); }
/// <summary>Base constructor</summary> /// <param name="clientConfig">Client protocol configuration.</param> public WebSocketClientProtocolHandler(WebSocketClientProtocolConfig clientConfig) : base(CheckNotNull(clientConfig).DropPongFrames, clientConfig.SendCloseFrame, clientConfig.ForceCloseTimeoutMillis) { _handshaker = WebSocketClientHandshakerFactory.NewHandshaker( clientConfig.WebSocketUri, clientConfig.Version, clientConfig.Subprotocol, clientConfig.AllowExtensions, clientConfig.CustomHeaders, clientConfig.MaxFramePayloadLength, clientConfig.PerformMasking, clientConfig.AllowMaskMismatch, clientConfig.ForceCloseTimeoutMillis, clientConfig.AbsoluteUpgradeUrl ); _clientConfig = clientConfig; }
internal Builder(WebSocketClientProtocolConfig clientConfig) { if (clientConfig is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.clientConfig); } _webSocketUri = clientConfig.WebSocketUri; _subprotocol = clientConfig.Subprotocol; _version = clientConfig.Version; _allowExtensions = clientConfig.AllowExtensions; _customHeaders = clientConfig.CustomHeaders; _maxFramePayloadLength = clientConfig.MaxFramePayloadLength; _performMasking = clientConfig.PerformMasking; _allowMaskMismatch = clientConfig.AllowMaskMismatch; _handleCloseFrames = clientConfig.HandleCloseFrames; _sendCloseFrame = clientConfig.SendCloseFrame; _dropPongFrames = clientConfig.DropPongFrames; _handshakeTimeoutMillis = clientConfig.HandshakeTimeoutMillis; _forceCloseTimeoutMillis = clientConfig.ForceCloseTimeoutMillis; _absoluteUpgradeUrl = clientConfig.AbsoluteUpgradeUrl; _withUTF8Validator = clientConfig.WithUTF8Validator; }