private bool upgradeToWebSocket(HttpListenerContext context) { var res = context.Response; var wsContext = context.AcceptWebSocket(); var socket = wsContext.WebSocket; var path = Ext.UrlDecode(wsContext.Path); IServiceHost svcHost; if (!_services.TryGetServiceHost(path, out svcHost)) { res.StatusCode = (int)HttpStatusCode.NotImplemented; return(false); } svcHost.BindWebSocket(socket); return(true); }
/// <summary> /// Accepts a WebSocket connection. /// </summary> /// <param name="context"> /// A <see cref="TcpListenerWebSocketContext"/> that contains a WebSocket connection. /// </param> protected override void AcceptWebSocket(TcpListenerWebSocketContext context) { var socket = context.WebSocket; var path = context.Path.UrlDecode(); IServiceHost svcHost; if (!_services.TryGetServiceHost(path, out svcHost)) { socket.Close(HttpStatusCode.NotImplemented); return; } if (BaseUri.IsAbsoluteUri) { socket.Url = new Uri(BaseUri, path); } svcHost.BindWebSocket(socket); }
protected override void AcceptWebSocket(TcpClient client) { var context = Ext.AcceptWebSocket(client, IsSecure); var socket = context.WebSocket; var path = Ext.UrlDecode(context.Path); IServiceHost svcHost; if (!_services.TryGetServiceHost(path, out svcHost)) { socket.Close(HttpStatusCode.NotImplemented); return; } if (BaseUri.IsAbsoluteUri) { socket.Url = new Uri(BaseUri, path); } svcHost.BindWebSocket(socket); }