Have no idea about this, you might check this file src\SuperSocket.WebSocket.Server\WebSocketPackageHandler.cs
Then find the implementation of IWebSocketCommandMiddleware and ISubProtocolHandler
public async ValueTask Handle(IAppSession session, WebSocketPackage package)
{
var websocketSession = session as WebSocketSession;
if (package.OpCode == OpCode.Handshake)
{
websocketSession.HttpHeader = package.HttpHeader;
// handshake failure
if (!(await HandleHandshake(websocketSession, package)))
{
websocketSession.CloseWithoutHandshake();
return;
}
websocketSession.Handshaked = true;
await _websocketServerMiddleware.HandleSessionHandshakeCompleted(websocketSession);
return;
}
if (!websocketSession.Handshaked)
{
// not pass handshake but receive data package now
// impossible routine
return;
}
if (package.OpCode == OpCode.Close)
{
if (websocketSession.CloseStatus == null)
{
var closeStatus = GetCloseStatusFromPackage(package);
websocketSession.CloseStatus = closeStatus;
try
{
await websocketSession.SendAsync(package);
}
catch (InvalidOperationException)
{
// support the case the client close the connection right after it send the close handshake
}
}
else
{
websocketSession.CloseWithoutHandshake();
}
return;
}
else if (package.OpCode == OpCode.Ping)
{
package.OpCode = OpCode.Pong;
await websocketSession.SendAsync(package);
return;
}
else if (package.OpCode == OpCode.Pong)
{
// don't do anything for Pong for now
return;
}
var protocolHandler = websocketSession.SubProtocolHandler;
if (protocolHandler != null)
{
await protocolHandler.Handle(session, package);
return;
}
// application command
var websocketCommandMiddleware = _websocketCommandMiddleware;
if (websocketCommandMiddleware != null)
{
await websocketCommandMiddleware.Handle(session, package);
return;
}
var packageHandleDelegate = _packageHandlerDelegate;
if (packageHandleDelegate != null)
await packageHandleDelegate(websocketSession, package);
}
Have no idea about this, you might check this file src\SuperSocket.WebSocket.Server\WebSocketPackageHandler.cs Then find the implementation of IWebSocketCommandMiddleware and ISubProtocolHandler
Also check the logic in Handle method