Skip to content

Instantly share code, notes, and snippets.

@smpnjn
Created May 22, 2021 18:23
Show Gist options
  • Save smpnjn/76ca62f3ad92bf3d602c6836024fd3ca to your computer and use it in GitHub Desktop.
Save smpnjn/76ca62f3ad92bf3d602c6836024fd3ca to your computer and use it in GitHub Desktop.
// Get the /ws websocket route
app.ws('/ws', async function(ws, req) {
ws.on('message', async function(msg) {
// What was the message?
console.log(msg);
// Send back some data
ws.send(JSON.stringify({
"append" : true,
"returnText" : "I am using websockets!"
}));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment