public CreateMessageWriter ( WebSocketMessageType messageType ) : WebSocketMessageWriteStream | ||
messageType | WebSocketMessageType | |
Résultat | WebSocketMessageWriteStream |
public void With_WebSocket_CanWriteTwoSequentialMessages() { var handshake = GenerateSimpleHandshake(); using (var ms = new MemoryStream()) using (WebSocket ws = new WebSocketRfc6455(ms, new WebSocketListenerOptions() { PingTimeout = Timeout.InfiniteTimeSpan }, new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1), new IPEndPoint(IPAddress.Parse("127.0.0.1"), 2), handshake.Request, handshake.Response, handshake.NegotiatedMessageExtensions)) { using (var writer = ws.CreateMessageWriter(WebSocketMessageType.Text)) { } using (var writer = ws.CreateMessageWriter(WebSocketMessageType.Text)) { } } }
public void With_WebSocket_FailsWithDoubleMessageWrite() { Assert.Throws<WebSocketException>(() => { var handshake = GenerateSimpleHandshake(); using (var ms = new MemoryStream()) using ( WebSocket ws = new WebSocketRfc6455(ms, new WebSocketListenerOptions() { PingTimeout = Timeout.InfiniteTimeSpan }, new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1), new IPEndPoint(IPAddress.Parse("127.0.0.1"), 2), handshake.Request, handshake.Response, handshake.NegotiatedMessageExtensions)) { var writer = ws.CreateMessageWriter(WebSocketMessageType.Text); writer = ws.CreateMessageWriter(WebSocketMessageType.Text); } }); }