diff --git a/src/js/ripple/server.js b/src/js/ripple/server.js index b7a342d0..506a84d9 100644 --- a/src/js/ripple/server.js +++ b/src/js/ripple/server.js @@ -15,51 +15,64 @@ var utils = require('./utils'); @param cfg Configuration parameters. */ -var Server = function (remote, cfg) -{ +var Server = function (remote, cfg) { EventEmitter.call(this); - if ("object" !== typeof cfg || "string" !== typeof cfg.url) { - throw new Error("Invalid server configuration."); + + if ('object' !== typeof cfg || 'string' !== typeof cfg.url) { + throw new Error('Invalid server configuration.'); } - this._remote = remote; - this._cfg = cfg; + var self = this; - this._ws = null; - this._connected = false; + this._remote = remote; + this._cfg = cfg; + + this._ws = void(0); + this._connected = false; this._should_connect = false; - this._state = null; + this._state = void(0); - this._id = 0; - this._retry = 0; + this._id = 0; + this._retry = 0; - this._requests = {}; + this._requests = { }; - this.on('message', this._handle_message.bind(this)); - this.on('response_subscribe', this._handle_response_subscribe.bind(this)); + this.on('message', function(message) { + self._handle_message(message); + }); + + this.on('response_subscribe', function(message) { + self._handle_response_subscribe(message); + }); }; //------------------------------------------------------------------------------ util.inherits(Server, EventEmitter); +function to_set(list) { + var result = { }; + for (var i=0; i