Removes UI dependancies in the xmpp module.

This commit is contained in:
hristoterezov
2015-01-23 17:36:17 +02:00
parent 29b3ea07e0
commit 899f0ee83d
10 changed files with 194 additions and 142 deletions

View File

@@ -132,6 +132,20 @@ function processMessage(event)
}
function setupListeners() {
xmpp.addListener(XMPPEvents.MUC_ENTER, function (from) {
API.triggerEvent("participantJoined", {jid: from});
});
xmpp.addListener(XMPPEvents.MESSAGE_RECEIVED, function (from, nick, txt, myjid) {
if (from != myjid)
API.triggerEvent("incomingMessage",
{"from": from, "nick": nick, "message": txt});
});
xmpp.addListener(XMPPEvents.MUC_LEFT, function (jid) {
API.triggerEvent("participantLeft", {jid: jid});
});
}
var API = {
/**
* Check whether the API should be enabled or not.
@@ -160,6 +174,7 @@ var API = {
window.attachEvent('onmessage', processMessage);
}
sendMessage({type: "system", loaded: true});
setupListeners();
},
/**
* Checks whether the event is enabled ot not.