diff --git a/js/protocol.js b/js/protocol.js index 3a12e7f..fc9a81f 100644 --- a/js/protocol.js +++ b/js/protocol.js @@ -1,5 +1,23 @@ var Protocol = function() { var self = this; + + self.isEvent = function(receivedMessage) { + /* + * Determines whether or not the received message + * is an event. + * + * Right now, only the presence of an id is checked, + * as messages from the client don't specify the ID + * + * FIXME: check content of the id to dermine if message is an event + */ + if (receivedMessage['id']) { + return true; + } else { + return false; + } + } + var getInfo = function() { var info = {}; info.key = getString(); diff --git a/js/websockets.js b/js/websockets.js index 472d5de..148869b 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -206,12 +206,12 @@ weechat.factory('connection', ['$rootScope', '$http', 'handlers', 'colors', func var parseMessage = function(message) { - if (!message['id']) { - // should only be in case of hda objects - parseObjects(message['objects']); - } else { + if (protocol.isEvent(message)) { handlers.handleEvent(message); + } else { + parseObjects(message['objects']); } + };