public Task AcceptWebSocketRequest(Func <IWebSocket, Task> callback)
        {
#if NET45
            return(_httpListenerContext.AcceptWebSocketAsync(subProtocol: null).Then(ws =>
            {
                var handler = new SignalR.WebSockets.DefaultWebSocketHandler();
                var task = handler.ProcessWebSocketRequestAsync(ws);
                callback(handler).Then(h => h.CleanClose(), handler);
                return task;
            }));
#else
            throw new NotSupportedException();
#endif
        }
Ejemplo n.º 2
0
        public Task AcceptWebSocketRequest(Func <IWebSocket, Task> callback)
        {
#if NET45
            _context.AcceptWebSocketRequest(ws =>
            {
                var handler = new SignalR.WebSockets.DefaultWebSocketHandler();
                var task    = handler.ProcessWebSocketRequestAsync(ws);
                callback(handler).Then(h => h.CleanClose(), handler);
                return(task);
            });

            return(TaskAsyncHelper.Empty);
#else
            throw new NotSupportedException();
#endif
        }
Ejemplo n.º 3
0
 public Task AcceptWebSocketRequest(Func<IWebSocket, Task> callback)
 {
     #if NET45
     return _httpListenerContext.AcceptWebSocketAsync(subProtocol: null).Then(ws =>
     {
         var handler = new SignalR.WebSockets.DefaultWebSocketHandler();
         var task = handler.ProcessWebSocketRequestAsync(ws.WebSocket);
         callback(handler).Catch()
                          .ContinueWith(t => handler.End());
         return task;
     });
     #else
     throw new NotSupportedException();
     #endif
 }
Ejemplo n.º 4
0
        public Task AcceptWebSocketRequest(Func<IWebSocket, Task> callback)
        {
            #if NET45
            _context.AcceptWebSocketRequest(ws =>
            {
                var handler = new SignalR.WebSockets.DefaultWebSocketHandler();
                var task = handler.ProcessWebSocketRequestAsync(ws);
                callback(handler).Then(h => h.CleanClose(), handler);
                return task;
            });

            return TaskAsyncHelper.Empty;
            #else
            throw new NotSupportedException();
            #endif
        }