Created
January 31, 2018 13:55
-
-
Save ajitsinghkamal/e6b596549c7e3f463c26b12008007b1a to your computer and use it in GitHub Desktop.
establish websocket connection over websocket protocol
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
// use a websocket object | |
// uses websocket API | |
const socket = new WebSocket('ws url', [supported protocols]) | |
//set up an event listener for incoming messages | |
socket.onmessage = (event) => { | |
//do something | |
console.log(event.data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment