Created
February 27, 2019 05:11
-
-
Save devarajchidambaram/83a977427035d70fdb0fa2acd91d2fd6 to your computer and use it in GitHub Desktop.
Websocket in nodejs
This file contains hidden or 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
| var url = 'ws://localhost:8080/' | |
| var connection = new WebSocket(url) | |
| connection.onerror = error => { | |
| console.log(`WebSocket error: ${error}`) | |
| } | |
| connection.onopen = () => { | |
| connection.send('hey') | |
| } | |
| connection.onmessage = e => { | |
| console.log(e.data) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment