Ejemplo n.º 1
0
 public Task <WebSocket> AcceptWebSocketAsync(TimeSpan keepAliveInterval)
 {
     // WebSocket protocol 10
     if (Request.Headers.ContainsKey("upgrade") && Request.Headers["upgrade"].ToLower() == "websocket")
     {
         return(WebSocket10.AcceptAsync(this, keepAliveInterval));
     }
     // polling emulated WebSocket
     else if (Request.QueryString.ContainsKey("socket") && (Request.QueryString["socket"] == "poll") &&
              Request.QueryString.ContainsKey("command") && (Request.QueryString["command"] == "open"))
     {
         return(EmuPollSocket.AcceptAsync(this, keepAliveInterval));
     }
     else
     {
         throw new Exception("Request is not a WebSocket");
     }
 }