resources/plezi_client.js in plezi-0.12.19 vs resources/plezi_client.js in plezi-0.12.20
- old
+ new
@@ -34,10 +34,12 @@
// Connect Websocket
this.reconnect();
// auto-reconnection
this.autoreconnect = false;
this.reconnect_interval = 200
+ // dump data to console?
+ this.log_events = false
// the timeout for a message ack receipt
this.emit_timeout = false
// Set the autoreconnect property
if(autoreconnect) {this.autoreconnect = true;}
}
@@ -62,10 +64,11 @@
}
// The Websocket onmessage callback
PleziClient.prototype.___on_message = function(e) {
try {
var msg = JSON.parse(e.data);
+ if (this.owner.log_events) {console.log(msg)}
if ( msg.event == '_ack_') { clearTimeout(msg._EID_) }
if ( (msg.event) && (this.owner[msg.event])) {
this.owner[msg.event](msg);
} else if ( (msg.event) && (this.owner['on' + msg.event])) {
console.warn('PleziClient: use a callback called "' + msg.event +
@@ -105,10 +108,10 @@
this.connected = NaN;
this.ws = new WebSocket(this.url);
// lets us access the client from the callbacks
this.ws.owner = this
// The Websocket onopen callback
- this.ws.on_open = this.___on_open
+ this.ws.onopen = this.___on_open
// The Websocket onclose callback
this.ws.onclose = this.___on_close
// The Websocket onerror callback
this.ws.onerror = this.___on_error
// The Websocket onmessage callback