1
0
Fork 0

brutal disco

master
Matthieu Lalonde 14 years ago committed by Mathieu Lecarme
parent c0a68b4a5f
commit f448b78df1

@ -17,7 +17,7 @@ var Client = function(params) {
this.roster = {};
this.xmpp = new xmpp.Client(params);
this.xmpp.addListener('rawStanza', function(stanza) {
sys.debug("RAW: "[jabber.color] + stanza.toString().white);
//sys.debug("RAW: "[jabber.color] + stanza.toString().white);
});
this.xmpp.addListener('authFail', function() {
sys.error("[Error] Jabber : Authentication failure");
@ -76,6 +76,17 @@ var Client = function(params) {
var query = stanza.getChild('query', 'http://jabber.org/protocol/disco#info');
if(query != null) {
sys.debug((stanza.attrs.from + " wont to disco!")[jabber.color]);
jabber.resultIq(stanza, new xmpp.Element('query', {xmlns: 'http://jabber.org/protocol/disco#info'})
.c('feature', {'var': 'http://jabber.org/protocol/disco#info'}).up()
.c('feature', {'var': 'http://jabber.org/protocol/disco#items'}).up()
.c('feature', {'var': 'http://jabber.org/protocol/muc'}).up()
.c('identity', {
category: 'conference',
type: 'text',
name: 'Play-Specific Chatrooms'
}).up()
.tree()
);
}
});
};
@ -105,7 +116,7 @@ Client.prototype.askForRoster = function() {
name: child.attrs.name,
subscription: child.attrs.subscription};
});
jabber._debug("ROSTER : " + JSON.stringify(jabber.roster));
jabber._debug("ROSTER : "[jabber.color] + JSON.stringify(jabber.roster));
jabber.emit('roster', iq);
});
};
@ -116,6 +127,15 @@ Client.prototype.iq = function(iq, callback) {
this.xmpp.send(new xmpp.Element('iq', {type:"get", id: n}).cnode(iq).tree());
};
Client.prototype.resultIq = function(iqGet, result) {
this.xmpp.send(new xmpp.Element('iq', {
type: 'result',
from: iqGet.attrs.to,
to: iqGet.attrs.from,
id: iqGet.attrs.id
}).cnode(result).tree());
};
Client.prototype.presence = function(type) {
this.xmpp.send(new xmpp.Element('presence', (type != null) ? {type: type} : {}).tree());
};

Loading…
Cancel
Save