Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strophe.muc plugin and backbone inproper callback binding

After the first group message the strophe.muc plugin doesn't react on the following messages. I get the first presence, message and roster from the room, but all subsequent messages and presence stanzas will not trigger the functions. I think there is something wrong with the lines:

this.rooms[room].addHandler('message', msg_handler_cb);
this.rooms[room].addHandler('presence', pres_handler_cb);
this.rooms[room].addHandler('roster', roster_cb);

my code:

    join: function(){
          console.log("joining room");
          var self = this;
          connection.muc.join("[email protected]", "john", self.onMessage,  self.onPresence, self.onRoster);
      },

    onMessage: function(message){            
          var self = this;       
         var body = $(message).text();
         var from = $(message).attr("from");
         console.log(body);
         console.log(from);
      },
      onPresence: function(presence){
          console.log("onPresence");
          console.log(presence);
      },
      onRoster: function(roster){
          console.log("onRoster");
          console.log(roster);
      },
like image 458
genericatz Avatar asked Nov 21 '25 01:11

genericatz


1 Answers

Handlers that wish to continue being invoked should return true.

So just append return true; to all your handlers.

It's mentioned in the docs: http://strophe.im/strophejs/doc/1.0.2/files2/strophe-js.html

like image 133
JC Brand Avatar answered Nov 23 '25 14:11

JC Brand