Skip to content

Instantly share code, notes, and snippets.

@devarajchidambaram
Created February 27, 2019 05:11
Show Gist options
  • Select an option

  • Save devarajchidambaram/83a977427035d70fdb0fa2acd91d2fd6 to your computer and use it in GitHub Desktop.

Select an option

Save devarajchidambaram/83a977427035d70fdb0fa2acd91d2fd6 to your computer and use it in GitHub Desktop.
Websocket in nodejs
var url = 'ws://localhost:8080/'
var connection = new WebSocket(url)
connection.onerror = error => {
console.log(`WebSocket error: ${error}`)
}
connection.onopen = () => {
connection.send('hey')
}
connection.onmessage = e => {
console.log(e.data)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment