I tried this in Unity, with a websocket server build with aspnetcore. But when try to perform Connect() or ConnectAsyc(), the server recieve a http request with HttpContext.WebSockets.IsWebSocketRequest being false, thus the socket cannot be established. Has anyone get some clue?
In the server side, controller's code being like:
[HttpGet("/testWebSocket")]
public async Task WebSocketServer()
{
if (HttpContext.WebSockets.IsWebSocketRequest)//it's always false in here.
{
try
{
_socket = await HttpContext.WebSockets.AcceptWebSocketAsync();
await new WebSocketHelper().WebSocketReceive(_socket);
}
catch (Exception e) {
}
}
}
I tried this in Unity, with a websocket server build with aspnetcore. But when try to perform Connect() or ConnectAsyc(), the server recieve a http request with HttpContext.WebSockets.IsWebSocketRequest being false, thus the socket cannot be established. Has anyone get some clue?
In the server side, controller's code being like: