Skip to content
Snippets Groups Projects
Commit 3a85f064 authored by mcmlxxix's avatar mcmlxxix
Browse files

check if callback is a function

throw exception on missing host or port
parent 65aff826
No related branches found
No related tags found
No related merge requests found
...@@ -71,16 +71,12 @@ function JSONClient(serverAddr,serverPort) { ...@@ -71,16 +71,12 @@ function JSONClient(serverAddr,serverPort) {
this.VERSION = "$Revision$".split(' ')[1]; this.VERSION = "$Revision$".split(' ')[1];
this.serverAddr=serverAddr; this.serverAddr=serverAddr;
if(this.serverAddr==undefined) { if(this.serverAddr==undefined)
this.serverAddr="bbs.thebrokenbubble.com"; throw("no host specified");
log(LOG_DEBUG,"using default server address: " + this.serverAddr);
}
this.serverPort=serverPort; this.serverPort=serverPort;
if(this.serverPort==undefined) { if(this.serverPort==undefined)
this.serverPort=10088; throw("no port specified");
log(LOG_DEBUG,"using default server port: " + this.serverPort);
}
this.settings={ this.settings={
CONNECTION_TIMEOUT: 5, CONNECTION_TIMEOUT: 5,
...@@ -247,7 +243,7 @@ function JSONClient(serverAddr,serverPort) { ...@@ -247,7 +243,7 @@ function JSONClient(serverAddr,serverPort) {
var packet=this.receive(); var packet=this.receive();
if(!packet) if(!packet)
return false; return false;
else if(this.callback) else if(typeof this.callback == "function")
this.callback(packet.data); this.callback(packet.data);
else else
this.updates.push(packet.data); this.updates.push(packet.data);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment