mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
Add the supervisor to the list if not already added
This commit is contained in:
@@ -31,6 +31,19 @@ function OnConnected()
|
|||||||
{
|
{
|
||||||
conn.addHandler(OnPresenceStanza, null, "presence");
|
conn.addHandler(OnPresenceStanza, null, "presence");
|
||||||
conn.addHandler(OnMessageStanza, null, "message");
|
conn.addHandler(OnMessageStanza, null, "message");
|
||||||
|
|
||||||
|
//check if supervisor on list, if not ask to authenticate
|
||||||
|
var roster_iq = $iq({type: "get"}).c('query', {xmlns: Strophe.NS.ROSTER});
|
||||||
|
|
||||||
|
conn.sendIQ(roster_iq, function (iq) {
|
||||||
|
if ($(iq).find('item[jid="' + SUPERVISOR_XMPP + '"]').length == 0)
|
||||||
|
{
|
||||||
|
//request to be on list
|
||||||
|
conn.send($pres({ to: SUPERVISOR_XMPP, type: "subscribe" }));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//send presence message
|
||||||
conn.send($pres().c('status').t(PRESENCE_MESSAGE));
|
conn.send($pres().c('status').t(PRESENCE_MESSAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,10 +92,15 @@ function OnPresenceStanza(stanza)
|
|||||||
var sShow = $(stanza).find('show').text();
|
var sShow = $(stanza).find('show').text();
|
||||||
//alert(sFrom + ':' + sType + ':' + sShow + ':' + sBareJid);
|
//alert(sFrom + ':' + sType + ':' + sShow + ':' + sBareJid);
|
||||||
|
|
||||||
// update status on screen if it is the supervisors status
|
if(sType == "subscribe" && sBareJid == SUPERVISOR_XMPP)
|
||||||
|
|
||||||
if (sBareJid == SUPERVISOR_XMPP)
|
|
||||||
{
|
{
|
||||||
|
// Send a 'subscribed' notification back to accept the incoming
|
||||||
|
// subscription request if it is the supervisor
|
||||||
|
conn.send($pres({ to: SUPERVISOR_XMPP, type: "subscribed" }));
|
||||||
|
}
|
||||||
|
else if (sBareJid == SUPERVISOR_XMPP)
|
||||||
|
{
|
||||||
|
// update status on screen if it is the supervisors status
|
||||||
if (sType == null || sType == '') {
|
if (sType == null || sType == '') {
|
||||||
sType = 'available';
|
sType = 'available';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user