I'm trying to use websocket-sharp for a project and the server needs to be able to drop websocket connections.
The connections are represented by a WebSocketBehavior class which you inherit from. There's no Stop
or Close
or Disconnect
method on WebSocketBehavior
. The closest I could find is
WebSocketBehavior.Context.WebSocket.Close
So I tried adding a method to my overriding class
public class MySocket : WebSocketBehavior
{
public void Close()
{
base.Context.WebSocket.Close();
}
}
But that causes an error when logging is turned on
2/5/2016 7:08:25 PM|Error|WebSocket.Close|This operation isn't available in: closed
How can the server disconnect/close a WebSocket connection?