private WebSocketSession( IWebSocketContext context) { _context = context; _keepAlive = new WebSocketKeepAlive(context, KeepAliveTimeout, _cts); _subscriptionReplier = new SubscriptionReplier( _pipe.Reader, new WebSocketPipeline(context, _cts), _cts); _subscriptionReceiver = new SubscriptionReceiver( context, _pipe.Writer, _cts); }
public async Task AfterTimeout_ReceiveKeepAlive() { // arrange var timeout = TimeSpan.FromMilliseconds(100); (WebSocketContext context, WebSocketMock socket) = WebSocketContextHelper.Create(); var keepAlive = new WebSocketKeepAlive( context, timeout, new CancellationTokenSource()); // act keepAlive.Start(); await Task.Delay(timeout.Add(TimeSpan.FromMilliseconds(500))); // assert Assert.True(socket.Outgoing.Any(t => t.Type.Equals(MessageTypes.Connection.KeepAlive))); }