Skip to content

Instantly share code, notes, and snippets.

@yakovenkodenis
Last active November 21, 2022 16:59
Show Gist options
  • Save yakovenkodenis/5adda311308e0cb7df012fc8c0bea4e3 to your computer and use it in GitHub Desktop.
Save yakovenkodenis/5adda311308e0cb7df012fc8c0bea4e3 to your computer and use it in GitHub Desktop.
const PORT = 4000.
const server = new WebSocketServer({ port: PORT });
server.on('data', (message) => {
if (!message) return;
const data = JSON.parse(message);
console.log('Message received:', data);
});
server.listen(() => {
console.log(`WebSocket server listening on port ${PORT}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment