Permalink
Browse files

Let server parse standard IRC commands.

  • Loading branch information...
1 parent 4e8cc43 commit ef79c82c65ff7b4d2afffa8e4dc3c1d5e586525d @akavlie akavlie committed Jan 14, 2012
Showing with 13 additions and 11 deletions.
  1. +10 −8 assets/js/client.js
  2. +3 −3 assets/js/views/chat.js
View
@@ -64,6 +64,7 @@ $(function() {
});
irc.socket.on('part', function(data) {
+ console.log('Part event received for ' + data.channel + ' - ' + data.nick);
var channel = irc.chatWindows.getByName(data.channel);
if (data.nick === irc.me.nick) {
channel.part();
@@ -81,14 +82,15 @@ $(function() {
});
irc.handleCommand = function(commandText) {
- switch(commandText[0]) {
- case 'join':
- irc.socket.emit('join', commandText[1]);
- break;
- case 'part':
- irc.socket.emit('part', commandText[1]);
- break;
- }
+ irc.socket.emit('command', commandText);
+ // switch(commandText[0]) {
+ // case 'join':
+ // irc.socket.emit('join', commandText[1]);
+ // break;
+ // case 'part':
+ // irc.socket.emit('part', commandText[1]);
+ // break;
+ // }
}
})
View
@@ -47,9 +47,9 @@ var ChatView = Backbone.View.extend({
if (event.keyCode == 13) {
var message = $(this).val();
// Handle IRC commands
- if (message.substr(0,1) === '/') {
- var command_text = message.substr(1).split(' ');
- irc.handleCommand(command_text);
+ if (message.substr(0, 1) === '/') {
+ var commandText = message.substr(1);
+ irc.handleCommand(commandText);
} else {
// Send the message
irc.socket.emit('say', {target: irc.chatWindows.getActive().get('name'), message:message});

0 comments on commit ef79c82

Please sign in to comment.