private void Initialize(WebSocketTransportDuplexSessionChannel webSocketTransportDuplexSessionChannel, WebSocket webSocket, bool useStreaming, IDefaultCommunicationTimeouts defaultTimeouts) { _webSocket = webSocket; _encoder = webSocketTransportDuplexSessionChannel.MessageEncoder; _bufferManager = webSocketTransportDuplexSessionChannel.BufferManager; _localAddress = webSocketTransportDuplexSessionChannel.LocalAddress; _maxBufferSize = webSocketTransportDuplexSessionChannel.MaxBufferSize; _handshakeSecurityMessageProperty = webSocketTransportDuplexSessionChannel.RemoteSecurity; _maxReceivedMessageSize = webSocketTransportDuplexSessionChannel.TransportFactorySettings.MaxReceivedMessageSize; _receiveBufferSize = Math.Min(WebSocketHelper.GetReceiveBufferSize(_maxReceivedMessageSize), _maxBufferSize); _useStreaming = useStreaming; _defaultTimeouts = defaultTimeouts; _closeDetails = webSocketTransportDuplexSessionChannel._webSocketCloseDetails; _asyncReceiveState = AsyncReceiveState.Finished; }
private WebSocketOptions CreateWebSocketOptions(HttpTransportBindingElement tbe) { // TODO: Is a check for IDuplexSessionChannel also needed? bool canUseWebSockets = tbe.WebSocketSettings.TransportUsage == WebSocketTransportUsage.Always || (tbe.WebSocketSettings.TransportUsage == WebSocketTransportUsage.WhenDuplex && _serviceDispatcher.SupportedChannelTypes.Contains(typeof(IDuplexChannel))); if (!canUseWebSockets) { return(null); } return(new WebSocketOptions { ReceiveBufferSize = WebSocketHelper.GetReceiveBufferSize(tbe.MaxReceivedMessageSize), KeepAliveInterval = tbe.WebSocketSettings.GetEffectiveKeepAliveInterval() }); }