-
-
Save dom96/26c574ec1491ba98181de6c532fa52fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let headers = req.headers.get() | |
# Set up AsyncSocket for use with asyncdispatch. | |
req.forget() # Remove from HttpBeast event loop. | |
asyncdispatch.register(req.client.AsyncFD) | |
let socket = newAsyncSocket(req.client.AsyncFD) | |
# Handshake with client. | |
let (client, error) = | |
await verifyWebsocketRequest(socket, headers, "stardust") | |
if error.len != 0: | |
game.logs.initialError.labels("negotiation").inc() | |
warn("WS negotiation failed: " & error) | |
req.send("Websocket negotiation failed: " & error, Http400) | |
socket.close() | |
else: | |
let success = await addPlayer(game, client) | |
if not success: | |
game.logs.initialError.labels("addPlayer").inc() | |
info("Dropping connection due to unsuccessful `addPlayer`") | |
await client.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment