Server config accessible to client object
authorDarren <darren@darrenwhitlen.com>
Sat, 6 Sep 2014 21:05:56 +0000 (22:05 +0100)
committerDarren <darren@darrenwhitlen.com>
Sat, 6 Sep 2014 21:05:56 +0000 (22:05 +0100)
server/client.js
server/weblistener.js

index 73a0cb24e9b208a0256a429bf68d37182412c4d5..0a88fbfaf2861c8dba8fe103698d20e6476b7bd6 100755 (executable)
@@ -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') {
index 8680cc82ecf03a8b44299a82a56c2cfb3b56239f..0a61821585829a21eeff35c9eefc73863eac893a 100644 (file)
@@ -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);
             });