aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Kavlie <akavlie@gmail.com>2011-11-11 21:20:47 -0700
committerAaron Kavlie <akavlie@gmail.com>2011-11-11 21:20:47 -0700
commitf6836bfab350de63cb3588899643e8fa4bab211f (patch)
tree3d4b437c65d055a6dabfe9dd61f0d4eef9e21316
parentd9a4cb2ecd978d932f54bc0cab051b1893865058 (diff)
downloadreevo-webirc-f6836bfab350de63cb3588899643e8fa4bab211f.tar.gz
reevo-webirc-f6836bfab350de63cb3588899643e8fa4bab211f.zip
Namespace socket events; handle empty channel list properly.
-rw-r--r--app.js12
-rw-r--r--server.js3
2 files changed, 9 insertions, 6 deletions
diff --git a/app.js b/app.js
index d8cbb93..1d28b49 100644
--- a/app.js
+++ b/app.js
@@ -437,10 +437,12 @@ $(function() {
437 connect: function(e) { 437 connect: function(e) {
438 e && e.preventDefault(); 438 e && e.preventDefault();
439 439
440 var channelInput = $('#connect-channels').val(),
441 channels = channelInput ? channelInput.split(' ') : [];
440 var connectInfo = { 442 var connectInfo = {
441 nick: $('#connect-nick').val(), 443 nick: $('#connect-nick').val(),
442 server: $('#connect-server').val(), 444 server: $('#connect-server').val(),
443 channels: $('#connect-channels').val().split(' ') 445 channels: channels
444 }; 446 };
445 447
446 socket.emit('connect', connectInfo); 448 socket.emit('connect', connectInfo);
@@ -542,14 +544,14 @@ $(function() {
542 }); 544 });
543 545
544 // Set topic event 546 // Set topic event
545 socket.on('topic', function(data) { 547 socket.on('irc:topic', function(data) {
546 var channel = frames.getByName(data.channel); 548 var channel = frames.getByName(data.channel);
547 channel.set({topic: data.topic}); 549 channel.set({topic: data.topic});
548 // TODO: Show this was changed by data.nick in the channel stream 550 // TODO: Show this was changed by data.nick in the channel stream
549 }); 551 });
550 552
551 // Nick change event 553 // Nick change event
552 socket.on('nick', function(data) { 554 socket.on('irc:nick', function(data) {
553 // Update my info, if it's me 555 // Update my info, if it's me
554 if (data.oldNick == irc.me.get('nick')) { 556 if (data.oldNick == irc.me.get('nick')) {
555 irc.me.set({nick: data.newNick}); 557 irc.me.set({nick: data.newNick});
@@ -571,7 +573,7 @@ $(function() {
571 }); 573 });
572 }); 574 });
573 575
574 socket.on('names', function(data) { 576 socket.on('irc:names', function(data) {
575 var frame = frames.getByName(data.channel); 577 var frame = frames.getByName(data.channel);
576 console.log(data); 578 console.log(data);
577 for (var nick in data.nicks) { 579 for (var nick in data.nicks) {
@@ -579,7 +581,7 @@ $(function() {
579 } 581 }
580 }); 582 });
581 583
582 socket.on('error', function(data) { 584 socket.on('irc:error', function(data) {
583 console.log(data.message); 585 console.log(data.message);
584 frame = frames.getActive(); 586 frame = frames.getActive();
585 error = humanizeError(data.message); 587 error = humanizeError(data.message);
diff --git a/server.js b/server.js
index bd382b8..e8ed6fb 100644
--- a/server.js
+++ b/server.js
@@ -59,10 +59,11 @@ io.sockets.on('connection', function(socket) {
59 args[arg] = callbackArgs[index]; 59 args[arg] = callbackArgs[index];
60 }); 60 });
61 console.log(args); 61 console.log(args);
62 socket.emit(event, args); 62 socket.emit('irc:' + event, args);
63 }); 63 });
64 }; 64 };
65 65
66 for (var event in events) { activateListener(event, events[event]); } 66 for (var event in events) { activateListener(event, events[event]); }
67 console.log('Starting IRC client; wiring up socket events.')
67 }); 68 });
68}); \ No newline at end of file 69}); \ No newline at end of file