Skip to content

Instantly share code, notes, and snippets.

@yakovenkodenis
Created November 21, 2022 16:59
Show Gist options
  • Save yakovenkodenis/96fd67b305f545e6f59616c3a5061ce8 to your computer and use it in GitHub Desktop.
Save yakovenkodenis/96fd67b305f545e6f59616c3a5061ce8 to your computer and use it in GitHub Desktop.
const PORT = 4000.
const server = new WebSocketServer({ port: PORT });
server.on('headers', ({ headers }) => console.log(headers));
server.on('data', (message, reply) => {
if (!message) return;
const data = JSON.parse(message);
return reply({ pong: data });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment