Last active
July 3, 2018 10:00
-
-
Save AlexDaSoul/392b9657aa59576fefdaf83a82ec9654 to your computer and use it in GitHub Desktop.
ws-5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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