Skip to content
Browse files

Namespace socket events; handle empty channel list properly.

  • Loading branch information...
1 parent d9a4cb2 commit f6836bfab350de63cb3588899643e8fa4bab211f @akavlie committed Nov 11, 2011
Showing with 9 additions and 6 deletions.
  1. +7 −5 app.js
  2. +2 −1 server.js
View
12 app.js
@@ -437,10 +437,12 @@ $(function() {
connect: function(e) {
e && e.preventDefault();
+ var channelInput = $('#connect-channels').val(),
+ channels = channelInput ? channelInput.split(' ') : [];
var connectInfo = {
nick: $('#connect-nick').val(),
server: $('#connect-server').val(),
- channels: $('#connect-channels').val().split(' ')
+ channels: channels
};
socket.emit('connect', connectInfo);
@@ -542,14 +544,14 @@ $(function() {
});
// Set topic event
- socket.on('topic', function(data) {
+ socket.on('irc:topic', function(data) {
var channel = frames.getByName(data.channel);
channel.set({topic: data.topic});
// TODO: Show this was changed by data.nick in the channel stream
});
// Nick change event
- socket.on('nick', function(data) {
+ socket.on('irc:nick', function(data) {
// Update my info, if it's me
if (data.oldNick == irc.me.get('nick')) {
irc.me.set({nick: data.newNick});
@@ -571,15 +573,15 @@ $(function() {
});
});
- socket.on('names', function(data) {
+ socket.on('irc:names', function(data) {
var frame = frames.getByName(data.channel);
console.log(data);
for (var nick in data.nicks) {
frame.participants.add({nick: nick, opStatus: data.nicks[nick]});
}
});
- socket.on('error', function(data) {
+ socket.on('irc:error', function(data) {
console.log(data.message);
frame = frames.getActive();
error = humanizeError(data.message);
View
3 server.js
@@ -59,10 +59,11 @@ io.sockets.on('connection', function(socket) {
args[arg] = callbackArgs[index];
});
console.log(args);
- socket.emit(event, args);
+ socket.emit('irc:' + event, args);
});
};
for (var event in events) { activateListener(event, events[event]); }
+ console.log('Starting IRC client; wiring up socket events.')
});
});

0 comments on commit f6836bf

Please sign in to comment.
Something went wrong with that request. Please try again.