Skip to content

Instantly share code, notes, and snippets.

@AlexDaSoul
Last active July 3, 2018 10:00
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 AlexDaSoul/392b9657aa59576fefdaf83a82ec9654 to your computer and use it in GitHub Desktop.
Save AlexDaSoul/392b9657aa59576fefdaf83a82ec9654 to your computer and use it in GitHub Desktop.
ws-5
const ws = new WebSocket("ws://www.example.com");
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.event === 'user') {
// ...
}
if (data.event === 'news') {
// ...
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment