Created
March 19, 2019 12:17
-
-
Save Krknv/1fdd61da27e17aff64f6fe3ff929356a to your computer and use it in GitHub Desktop.
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 = 'http://sample.com' | |
var ws = new WebSocket(url); | |
var msg = "hi, this is simple message."; | |
ws.onopen = function(evt) { | |
ws.send(msg); | |
}; | |
ws.onmessage = function(evt) { | |
// handle this message | |
console.log(evt.data); | |
}; | |
ws.onclose = function(evt) { | |
// this channel is closed | |
}; | |
ws.onerror = function(evt) { | |
// handle this error | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment