Created
May 22, 2021 18:24
-
-
Save smpnjn/69c3e7ae3bd81a64fff339377982fd16 to your computer and use it in GitHub Desktop.
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
// When the document has loaded | |
document.addEventListener('DOMContentLoaded', function() { | |
// Connect to the websocket | |
connect(); | |
// And add our event listeners | |
document.getElementById('websocket-button').addEventListener('click', function(e) { | |
if(isOpen(socket)) { | |
socket.send(JSON.stringify({ | |
"data" : "this is our data to send", | |
"other" : "this can be in any format" | |
})) | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment