Files
main.tsmain
What you'll learn
- Write a guard for a gateway, reach the socket with context.switchToWs().getClient(), and refuse with a WsException that says why
- Know what a guard that returns false sends: an exception event with Forbidden resource
- Refuse a connection at the handshake with a socket.io middleware, server.use(), and know what the client receives: connect_error with the error's message
- Extend IoAdapter, override createIOServer(), and install it with app.useWebSocketAdapter()
Press Run tests to start the app. Its log appears here.Graded endpoints
The adapter's middleware runs before the connection exists and refuses it; the client gets connect_error with the error's message, and no handler or hook ever runs
Spaces are not a name either
The middleware lets her in
What the middleware put in socket.data reaches every handler, trimmed
Messages without a guard are open to every visitor
The guard finds no staff token in her handshake and throws a WsException; the handler never runs
Sam's handshake carries a name and the staff token
The guard lets the message through
Past the guard, the handler's own rules apply
Only Sam's removal happened
run the tests first
Frames
Run the tests first.