我正在测试使用strophe库构建的聊天应用程序。我添加了一些函数来处理strophe处理程序的回调。如何测试我的回调函数?
我已经成功地附着于strophe,并且得到了存在节。但是如何测试状态?
url = '' //endpoint url
connection = new XMPP.Strophe.Connection(url, { keepalive: true });
//connect strophe
connectStorph(jid, sid, rid) {
this.connection.attach(jid, sid, rid, (callback) => { this.onConnect(callback); });
}
onConnect(status) {
if (status === XMPP.Strophe.Status.ATTACHED) {
this.connection.addHandler((callback) => { this.onPresence(callback); return true; }, null, 'presence');
}
}
onPresence(presence){
// added functionality
}