| 1 |
using Gee; |
| 2 |
|
| 3 |
namespace Xmpp.Xep.Ping { |
| 4 |
private const string NS_URI = "urn:xmpp:ping"; |
| 5 |
|
| 6 |
public class Module : XmppStreamModule, Iq.Handler { |
| 7 |
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0199_ping"); |
| 8 |
|
| 9 |
public async Iq.Stanza send_ping(XmppStream stream, Jid jid) { |
| 10 |
StanzaNode ping_node = new StanzaNode.build("ping", NS_URI).add_self_xmlns(); |
| 11 |
Iq.Stanza iq = new Iq.Stanza.get(ping_node) { to=jid }; |
| 12 |
return yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq, Priority.HIGH); |
| 13 |
} |
| 14 |
|
| 15 |
public override void attach(XmppStream stream) { |
| 16 |
stream.get_module(Iq.Module.IDENTITY).register_for_namespace(NS_URI, this); |
| 17 |
stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI); |
| 18 |
} |
| 19 |
|
| 20 |
public override void detach(XmppStream stream) { |
| 21 |
stream.get_module(Iq.Module.IDENTITY).unregister_from_namespace(NS_URI, this); |
| 22 |
stream.get_module(ServiceDiscovery.Module.IDENTITY).remove_feature(stream, NS_URI); |
| 23 |
} |
| 24 |
|
| 25 |
public async void on_iq_get(XmppStream stream, Iq.Stanza iq) { |
| 26 |
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, new Iq.Stanza.result(iq), null, Priority.HIGH); |
| 27 |
} |
| 28 |
|
| 29 |
public override string get_ns() { return NS_URI; } |
| 30 |
public override string get_id() { return IDENTITY.id; } |
| 31 |
} |
| 32 |
} |