Skip to content

Instantly share code, notes, and snippets.

@mattes
Created March 12, 2019 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattes/6c0bc186a7f013482d2b2d1c67a485ed to your computer and use it in GitHub Desktop.
Save mattes/6c0bc186a7f013482d2b2d1c67a485ed to your computer and use it in GitHub Desktop.
ws = new WebSocket("ws://localhost:8080");
ws.onopen = function(evt) {
console.log("OPEN");
}
ws.onclose = function(evt) {
console.log("CLOSE");
ws = null;
}
ws.onmessage = function(evt) {
console.log("RESPONSE: " + evt.data);
}
ws.onerror = function(evt) {
console.log("ERROR: " + evt.data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment