private async void ThreadListen() { //TODO graceful kill while (IsStarted) { try { var listenerContext = await _listener.GetContextAsync(); if (listenerContext.Request.IsWebSocketRequest) { WebSocketContext webSocketContext = await listenerContext.AcceptWebSocketAsync(subProtocol : null); var webSocket = webSocketContext.WebSocket; var connection = new WebsocketConnection(webSocket, webSocketContext.Origin); CreateClient(connection); } else { listenerContext.Response.StatusCode = 426; listenerContext.Response.Close(); } } catch (Exception e) { DoListenerException(e); } } }
public WebSocketMessageParser(WebsocketConnection comm) { _comm = comm; }