A small websocket server.
- Implement the abstract class
WebSocketServer
.
public class DummyServer : WebSocketServer
{
protected override void OnMessageReceived(IWebSocketConnection conn, string message)
{
conn.Send("Echo");
}
protected override void OnConnectionClosed(IWebSocketConnection conn)
{
throw new NotImplementedException();
}
protected override void OnConnectionOpened(IWebSocketConnection conn, HttpContext context)
{
throw new NotImplementedException();
}
}
- Register websockets and the websocket server
app.UseWebSockets();
app.UseWebSocketServer(new DummyServer());