本文整理汇总了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());
}
}
示例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();
}*/
}
示例3: ProcessRequest
public void ProcessRequest(HttpContext context)
{
if (context.IsWebSocketRequest)
{
context.AcceptWebSocketRequest(new MicrosoftWebSockets());
}
}
示例4: ProcessRequest
public void ProcessRequest(HttpContext context)
{
if (context.IsWebSocketRequest)
context.AcceptWebSocketRequest(this.HandleWebSocket);
else
context.Response.StatusCode = 400;
}
示例5: ProcessRequest
public void ProcessRequest(HttpContext context)
{
if (context.IsWebSocketRequest)
context.AcceptWebSocketRequest(new ChatWebsocket());
}
示例6: ProcessRequest
public void ProcessRequest(HttpContext context)
{
if (context.IsWebSocketRequest)
{
context.AcceptWebSocketRequest(ProcessWS);
}
}
示例7: ProcessRequest
public void ProcessRequest(HttpContext context)
{
if (context.IsWebSocketRequest || context.IsWebSocketRequestUpgrading)
{
context.AcceptWebSocketRequest(new G_Location_Handler());
}
}
示例8: ProcessRequestAsync
public override async Task ProcessRequestAsync(HttpContext context)
{
if (context.IsWebSocketRequest)
{
context.AcceptWebSocketRequest(WebSocketHandler);
}
}
示例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;
}
}
});
}
示例10: ProcessRequest
public void ProcessRequest(HttpContext context)
{
ClearExpiredSocket();
if (context.IsWebSocketRequest)
{
context.AcceptWebSocketRequest(ProcessChat);
}
}
示例11: ProcessRequest
public void ProcessRequest(HttpContext context)
{
if (context.IsWebSocketRequest)
{
var player = new GamePlayer();
FourInABruGame.Join(player);
context.AcceptWebSocketRequest(player.SocketReceiver);
}
}
示例12: ProcessRequest
public void ProcessRequest(HttpContext context)
{
var user = context.Request.Cookies["username"].Value;
if (context.IsWebSocketRequest)
{
context.AcceptWebSocketRequest(new ChatHandler(user));
}
}
示例13: ProcessRequest
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
if (context.IsWebSocketRequest)
{
context.AcceptWebSocketRequest(new SocketHandler());
}
}
示例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);
}
}
示例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");
}
}