在第一组消息之后,strophe.muc 插件不会对以下消息做出反应。我从房间中获得了第一个出席信息、消息和花名册,但所有后续消息和出席信息节都不会触发这些功能。我认为这些行有问题:
this.rooms[room].addHandler('message', msg_handler_cb);
this.rooms[room].addHandler('presence', pres_handler_cb);
this.rooms[room].addHandler('roster', roster_cb);
我的代码:
join: function(){
console.log("joining room");
var self = this;
connection.muc.join("room@conference.server", "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);
},