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 webSocket = new WebSocket('wss://echo.websocket.org'); | |
//Event listeners are the pillars upon which WebSockets are built. This event fires when the WebSocket is considered 'OPEN', | |
//which means that it has connected successfully. | |
webSocket.addEventListener('open', function(event) { | |
console.log('websocket connected successfully') //log this into the browser console so we can check if the websocket connected | |
}); | |
//This is a global reference to the websocket that we created. We need this because otherwise multiple JS |