function IO(){
	var secure = window.location.protocol.match(/https/);
	var socket = this.socket = new io.Socket(window.location.hostname, {
			secure: secure,
			port: secure ? '' : window.location.port
			,reconnectionDelay: 2000
		});

	var messageHandlers = [];

	socket.on('message', function(data){
		for(var i=0, len=messageHandlers.length; i<len; i++){
			var handler = messageHandlers[i];
			if(handler.newMessage(data)) break;
		}
	});
	
	this.connect = function(){
		socket.connect();
		socket.send({channel: channel, action: 'join', connector_id: connector_id});
	}
	
	this.addMessageHandler = function(handler){
		messageHandlers.push(handler);
	}
}

@@ -264,28 +264,29 @@
 ;%0A%0A%09
-socket.on('m
+this.processM
 essage
-',
+ =
  fun
@@ -436,18 +436,99 @@
 ;%0A%09%09%7D%0A%09%7D
-);
+%0A%09%0A%09this.addMessageHandler = function(handler)%7B%0A%09%09messageHandlers.push(handler);%0A%09%7D
 %0A%09%0A%09this
@@ -659,86 +659,49 @@
 %0A%09%0A%09
-this.addMessageHandler = function(handler)%7B%0A%09%09messageHandlers.push(handler);%0A%09%7D
+socket.on('message', this.processMessage);
 %0A%7D%0A

Refactor client IO.js