当前位置: 首页>>代码示例>>C#>>正文


C# HttpContext.AcceptWebSocketRequest方法代码示例

本文整理汇总了C#中System.Web.HttpContext.AcceptWebSocketRequest方法的典型用法代码示例。如果您正苦于以下问题:C# HttpContext.AcceptWebSocketRequest方法的具体用法?C# HttpContext.AcceptWebSocketRequest怎么用?C# HttpContext.AcceptWebSocketRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.HttpContext的用法示例。


在下文中一共展示了HttpContext.AcceptWebSocketRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessRequest

 public void ProcessRequest(HttpContext context)
 {
     if (context.IsWebSocketRequest || context.IsWebSocketRequestUpgrading)
     {
         context.AcceptWebSocketRequest(new Broadcaster());
     }
 }
开发者ID:playflute,项目名称:Captone-Project,代码行数:7,代码来源:AnimationHandler.ashx.cs

示例2: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            bool isSocket = false;
            WebSupport.InitializeContextStorage(context.Request);
            if (context.IsWebSocketRequest)
            {
                isSocket = true;
            }
            if (context.IsWebSocketRequest)
                context.AcceptWebSocketRequest(HandleWebSocket);
            else
                HandleNonWebsocketRequest(context);


            /*
            WebSupport.InitializeContextStorage(context.Request);
            try
            {
                if (request.Path.StartsWith(AuthEmailValidation))
                {
                    HandleEmailValidation(context);
                }        
            } finally
            {
                InformationContext.ProcessAndClearCurrent();
            }*/
        }
开发者ID:kallex,项目名称:Caloom,代码行数:27,代码来源:WebSocketHandler.cs

示例3: ProcessRequest

 public void ProcessRequest(HttpContext context)
 {
     if (context.IsWebSocketRequest)
     {
         context.AcceptWebSocketRequest(new MicrosoftWebSockets());
     }
 }
开发者ID:DanWahlin,项目名称:HTML5CourseCode,代码行数:7,代码来源:WebSocketsServer2.ashx.cs

示例4: ProcessRequest

 public void ProcessRequest(HttpContext context)
 {
     if (context.IsWebSocketRequest)
         context.AcceptWebSocketRequest(this.HandleWebSocket);
     else
         context.Response.StatusCode = 400;
 }
开发者ID:jn2304,项目名称:top-push,代码行数:7,代码来源:WebSocketHandler.cs

示例5: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {

            if (context.IsWebSocketRequest)
                context.AcceptWebSocketRequest(new ChatWebsocket());

        }
开发者ID:PrincessMadMath,项目名称:EstatePrediction_ConUHack,代码行数:7,代码来源:WsHttpHandler.ashx.cs

示例6: ProcessRequest

 public void ProcessRequest(HttpContext context)
 {
     if (context.IsWebSocketRequest)
     {
         context.AcceptWebSocketRequest(ProcessWS);
     }
 }
开发者ID:SyedArifulIslamEmon,项目名称:ChatSystem,代码行数:7,代码来源:WebSocketHandler.ashx.cs

示例7: ProcessRequest

 public void ProcessRequest(HttpContext context)
 {
     if (context.IsWebSocketRequest || context.IsWebSocketRequestUpgrading)
     {
         context.AcceptWebSocketRequest(new G_Location_Handler());
     }
 }
开发者ID:playflute,项目名称:Captone-Project,代码行数:7,代码来源:GeolocationHandler.ashx.cs

示例8: ProcessRequestAsync

 public override async Task ProcessRequestAsync(HttpContext context)
 {
     if (context.IsWebSocketRequest)
     {
         context.AcceptWebSocketRequest(WebSocketHandler);
     }
 }
开发者ID:dinandjait,项目名称:tim5,代码行数:7,代码来源:RecognizerService.ashx.cs

示例9: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            context.AcceptWebSocketRequest(async sc =>
            {
                var socket = sc.WebSocket;
                while(true)
                {
                    var buffer = new ArraySegment<byte>(new byte[1024]);
                    await socket.ReceiveAsync(buffer, CancellationToken.None);
                    if (socket.State == WebSocketState.Open)
                    {
                        var message = Encoding.UTF8.GetString(buffer.Array, 0, buffer.Count);
                        var response = "Hello from WebSockets, " + message + ". The time is: " + DateTime.Now.ToShortTimeString();
                        var responseBuffer = new ArraySegment<byte>(Encoding.UTF8.GetBytes(response));
                        for (var i = 0; i < 5; i++)
                        {
                            var q = new ArraySegment<byte>(Encoding.UTF8.GetBytes("Hello " + i));
                            await socket.SendAsync(q, WebSocketMessageType.Text, true, CancellationToken.None);
                            Thread.Sleep(2000);
                        }

                        await socket.SendAsync(responseBuffer, WebSocketMessageType.Text, true, CancellationToken.None);
                    }
                    else
                    {
                        break;
                    }
                }
            });
        }
开发者ID:vcsjones,项目名称:Presentations,代码行数:30,代码来源:Greeter.ashx.cs

示例10: ProcessRequest

 public void ProcessRequest(HttpContext context)
 {
     ClearExpiredSocket();
     if (context.IsWebSocketRequest)
     {
         context.AcceptWebSocketRequest(ProcessChat);
     }
 }
开发者ID:TeraTian,项目名称:MilitaryChess,代码行数:8,代码来源:WebSocketServer.ashx.cs

示例11: ProcessRequest

 public void ProcessRequest(HttpContext context)
 {
     if (context.IsWebSocketRequest)
       {
     var player = new GamePlayer();
     FourInABruGame.Join(player);
     context.AcceptWebSocketRequest(player.SocketReceiver);
       }
 }
开发者ID:PeterHimschoot,项目名称:Beers2U,代码行数:9,代码来源:GameHttpHandler.cs

示例12: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            var user = context.Request.Cookies["username"].Value;

            if (context.IsWebSocketRequest)
            {
                context.AcceptWebSocketRequest(new ChatHandler(user));
            }
        }
开发者ID:paulbatum,项目名称:BUILD-2011-WebSocket-Chat-Samples,代码行数:9,代码来源:chat.ashx.cs

示例13: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Write("Hello World");

            if (context.IsWebSocketRequest)
            {
                context.AcceptWebSocketRequest(new SocketHandler());
            }
        }
开发者ID:stanacton,项目名称:RemoteChat,代码行数:10,代码来源:BroadCastHandler.ashx.cs

示例14: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            if (context.IsWebSocketRequest)
            {
                // create a player
                var player = new PongPlayer();
                PongApp.JoinPlayer(player);

                // start receiving from socket
                context.AcceptWebSocketRequest(player.Receiver);
            }
        }
开发者ID:listellodavide,项目名称:csharp-tutorials,代码行数:12,代码来源:PongHttpHandler.cs

示例15: ProcessRequest

 public void ProcessRequest(HttpContext context)
 {
     if (context.IsWebSocketRequest)
     {
         context.AcceptWebSocketRequest(new WebSocketsAPIHandler());
     }
     else
     {
         context.Response.ContentType = "text/plain";
         context.Response.Write("Not WebSockets");
     }
 }
开发者ID:MooDevTeam,项目名称:Moo,代码行数:12,代码来源:WebSocketsAPI.ashx.cs


注:本文中的System.Web.HttpContext.AcceptWebSocketRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。