

module.exports = function(server, io, log, config) {

    function Client(socket, socketManager) {
        this.id = socket.id;
        this.socket = socket;
        this.reconnected = 0;
    }

    Client.prototype.setCredentials = function(creds) {
        this.credentials = creds;
    };

    Client.prototype.setDeviceInfo = function(deviceInfo) {
        this.deviceInfo = deviceInfo;
    };

    Client.prototype.emit = function(event, payload) {
        this.socket.emit(event, payload);
        //TODO: Handle completion through promise
    };

    Client.prototype.on = function(event, handler) {
        this.socket.on(event, handler);
    };

    Client.prototype.addHandler = function(handlerSpec) {
        this.socket.on(handlerSpec.key, handlerSpec.handler.bind(handlerSpec.scope));
    };

    return Client;
};

@@ -704,24 +704,50 @@
 dlerSpec) %7B%0A
+        var _this = this;%0A
         this
@@ -778,51 +778,302 @@
 ey, 
-handlerSpec.handler.bind(handlerSpec.scope)
+function(event) %7B%0A%0A            // We wrap the received event to share our client context with handlers%0A            handlerSpec.handler.bind(handlerSpec.scope)(%7B%0A                data:event,%0A                context: %7B%0A                    client: _this%0A                %7D%0A            %7D);%0A%0A        %7D
 );%0A 

Make sure to share client context when handler is called