From bede49f6e965b8c8bf80003fea9378adc01dbc9b Mon Sep 17 00:00:00 2001 From: Darren Date: Sat, 6 Sep 2014 22:05:56 +0100 Subject: [PATCH] Server config accessible to client object --- server/client.js | 5 ++++- server/weblistener.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/server/client.js b/server/client.js index 73a0cb2..0a88fbf 100755 --- a/server/client.js +++ b/server/client.js @@ -9,7 +9,7 @@ var util = require('util'), Stats = require('./stats.js'); -var Client = function (websocket) { +var Client = function (websocket, opts) { var that = this; Stats.incr('client.created'); @@ -17,6 +17,9 @@ var Client = function (websocket) { events.EventEmitter.call(this); this.websocket = websocket; + // Keep a record of how this client connected + this.server_config = opts.server_config; + this.rpc = new WebsocketRpc(this.websocket); this.rpc.on('all', function(func_name, return_fn) { if (typeof func_name === 'string' && typeof return_fn === 'function') { diff --git a/server/weblistener.js b/server/weblistener.js index 8680cc8..0a61821 100644 --- a/server/weblistener.js +++ b/server/weblistener.js @@ -122,7 +122,7 @@ var WebListener = module.exports = function (web_config) { return; } - client = new Client(socket); + client = new Client(socket, {server_config: web_config}); client.on('dispose', function () { that.emit('client_dispose', this); }); -- 2.25.1