Skip to content

Commit

Permalink
updated jquery
Browse files Browse the repository at this point in the history
  • Loading branch information
logsol committed Mar 23, 2012
1 parent 3f6bf90 commit 8902009
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
37 changes: 37 additions & 0 deletions public/javascripts/connector.js
@@ -0,0 +1,37 @@
function Connector(){
this.ip = null;
this.port = null;
this.socket = null;
}

Connector.prototype.connect = function(ip, port){
var self = this;
this.ip = ip;
this.port = port;

if(window.io === undefined){
self.onError('io not found (chatserver seems down)');
return false;
}

this.socket = io.connect(this.ip + ':' + this.port);
this.socket.reconnecting = false;
}

Connector.prototype.registerEvent = function(name, callback){
this.socket.on(name, callback);
}

Connector.prototype.send = function(method, data){
var transfer = {
method: method,
data: data
};
transfer = JSON.stringify(transfer);
this.socket.send(transfer);
console.log('sending: ' + transfer);
}

Connector.prototype.onError = function(message){
console.log(message);
}

0 comments on commit 8902009

Please sign in to comment.