Skip to content

Instantly share code, notes, and snippets.

@JanneSalokoski
Created January 22, 2017 08:20
Show Gist options
  • Save JanneSalokoski/a9897c78b271cf3e19c737671c6d5b44 to your computer and use it in GitHub Desktop.
Save JanneSalokoski/a9897c78b271cf3e19c737671c6d5b44 to your computer and use it in GitHub Desktop.
var URL = "http://localhost:8080/";
var Socket = function(url)
{
// Global properties
this.url = url;
this.connection = new WebSocket(URL);
// Global functions
this.send = function(msg)
{
this.connection.send(msg);
}
// Private functions
this.connection.onmessage = function (event)
{
console.log(event.data);
}
}
var socket = new WebSocket(URL);
socket.send("uik");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment