internal void SetWebSocketInfo(WebSocketContext webSocketContext, RemoteEndpointMessageProperty remoteEndpointMessageProperty, SecurityMessageProperty handshakeSecurityMessageProperty, byte[] innerBuffer, bool shouldDisposeWebSocketAfterClosed, HttpRequestMessage requestMessage) { Fx.Assert(webSocketContext != null, "webSocketContext should not be null."); this.ShouldDisposeWebSocketAfterClosed = shouldDisposeWebSocketAfterClosed; this.webSocketContext = webSocketContext; this.WebSocket = webSocketContext.WebSocket; this.InternalBuffer = innerBuffer; if (handshakeSecurityMessageProperty != null) { this.RemoteSecurity = handshakeSecurityMessageProperty; } bool inputUseStreaming = TransferModeHelper.IsRequestStreamed(this.TransferMode); this.webSocketMessageSource = new WebSocketMessageSource( this, this.webSocketContext, inputUseStreaming, remoteEndpointMessageProperty, this, requestMessage); this.SetMessageSource(this.webSocketMessageSource); }
private static void CheckResultAndEnsureNotCloseMessage(WebSocketMessageSource messageSource, WebSocketReceiveResult result) { messageSource.CheckCloseStatus(result); if (result.MessageType == WebSocketMessageType.Close) { throw Fx.Exception.AsError(new ProtocolException(SR.WebSocketUnexpectedCloseMessageError)); } }
public WebSocketStream( WebSocketMessageSource messageSource, ArraySegment <byte> initialBuffer, WebSocket webSocket, bool endofMessageReceived, BufferManager bufferManager, CancellationToken closeToken) : this(webSocket, WebSocketDefaults.DefaultWebSocketMessageType, closeToken) { Fx.Assert(messageSource != null, "messageSource should not be null."); _messageSource = messageSource; _initialReadBuffer = initialBuffer; _isForRead = true; _endofMessageReceived = endofMessageReceived; _bufferManager = bufferManager; _messageSourceCleanState = WebSocketHelper.OperationNotStarted; _endOfMessageWritten = WebSocketHelper.OperationNotStarted; }
internal void SetWebSocketInfo(WebSocketContext webSocketContext, RemoteEndpointMessageProperty remoteEndpointMessageProperty, SecurityMessageProperty handshakeSecurityMessageProperty, bool shouldDisposeWebSocketAfterClosed, HttpContext httpContext) { Fx.Assert(webSocketContext != null, "webSocketContext should not be null."); ShouldDisposeWebSocketAfterClosed = shouldDisposeWebSocketAfterClosed; _webSocketContext = webSocketContext; WebSocket = webSocketContext.WebSocket; if (handshakeSecurityMessageProperty != null) { RemoteSecurity = handshakeSecurityMessageProperty; } bool inputUseStreaming = TransferModeHelper.IsRequestStreamed(TransferMode); _webSocketMessageSource = new WebSocketMessageSource( this, _webSocketContext, inputUseStreaming, remoteEndpointMessageProperty, this, httpContext); SetMessageSource(_webSocketMessageSource); }
private static void OnAsyncReceiveCancelled(object target) { WebSocketMessageSource messageSource = (WebSocketMessageSource)target; messageSource.AsyncReceiveCancelled(); }
public WebSocketStream( WebSocketMessageSource messageSource, ArraySegment<byte> initialBuffer, WebSocket webSocket, bool endofMessageReceived, BufferManager bufferManager, TimeSpan closeTimeout) : this(webSocket, WebSocketDefaults.DefaultWebSocketMessageType, closeTimeout) { Fx.Assert(messageSource != null, "messageSource should not be null."); _messageSource = messageSource; _initialReadBuffer = initialBuffer; _isForRead = true; _endofMessageReceived = endofMessageReceived; _bufferManager = bufferManager; _messageSourceCleanState = WebSocketHelper.OperationNotStarted; _endOfMessageWritten = WebSocketHelper.OperationNotStarted; }
static void CheckResultAndEnsureNotCloseMessage(WebSocketMessageSource messageSource, WebSocketReceiveResult result) { messageSource.CheckCloseStatus(result); if (result.MessageType == WebSocketMessageType.Close) { throw FxTrace.Exception.AsError(new ProtocolException(SR.WebSocketUnexpectedCloseMessageError)); } }