Skip to content

Instantly share code, notes, and snippets.

@tsh-code
Created November 18, 2019 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsh-code/3f4a4efcd8bea9cb9100c597b082f1ec to your computer and use it in GitHub Desktop.
Save tsh-code/3f4a4efcd8bea9cb9100c597b082f1ec to your computer and use it in GitHub Desktop.
Typical WebSocket handler
io.on("connection", socket => {
socket.on("message", message => {
if (message.method === "JOIN_GAME") {
// DO SOMETHING
}
if (message.method === "LEAVE_GAME") {
// DO SOMETHING ELSE
}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment