From c984ba1b436c072e44c429d312e676199b937e8a Mon Sep 17 00:00:00 2001 From: Jack Allnutt Date: Wed, 13 Jul 2011 04:26:28 +0100 Subject: [PATCH] Modified front-end files --- index.php | 4 ++-- js/gateway.js | 46 +++++++++++++++++++++++++++++++++++++--------- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/index.php b/index.php index d1b1f45..cd43e8a 100644 --- a/index.php +++ b/index.php @@ -45,7 +45,7 @@ - + @@ -152,4 +152,4 @@ - \ No newline at end of file + diff --git a/js/gateway.js b/js/gateway.js index 610d6e5..065977f 100644 --- a/js/gateway.js +++ b/js/gateway.js @@ -8,9 +8,10 @@ var gateway = { channel_prefix: '#', network_name: '', user_prefixes: [], + socket: null, - connect: function(s_host, s_port, s_ssl, callback){ + /*connect: function(s_host, s_port, s_ssl, callback){ var data = { method: 'connect', args: { @@ -23,12 +24,14 @@ var gateway = { //$.post('poll.php', data, callback, 'json'); gateway.sendData(data, callback); - }, - + },*/ + connect: function(host,port,ssl,callback) { + socket.emit('irc connect', this.nick, host, port, ssl, function() { console.log('callback'); callback}); + }, - start: function(){ + /*start: function(){ if(typeof WebSocket != "undefined"){ //alert("Starting websocket support.."); gateway.socket(); @@ -36,10 +39,35 @@ var gateway = { //alert("Starting polling support.."); gateway.poll(); } + },*/ + start: function() { + socket = io.connect('http://192.168.1.127:7777/'); + socket.on('connection',function() { + gateway.sendData = function(data,callback) { + socket.send({sid:this.session_id,data:$.toJSON(data)},function(){console.log('callbacl'); callback}); + } + socket.on('message', function(msg) { + gateway.buffer += msg; + + if(gateway.buffer.indexOf("\n") > 0){ + var msgs = gateway.buffer.split("\n"); + for(var i=0; i