diff options
Diffstat (limited to 'xmpp-vala/src/module/xep/0199_ping.vala')
-rw-r--r-- | xmpp-vala/src/module/xep/0199_ping.vala | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/xmpp-vala/src/module/xep/0199_ping.vala b/xmpp-vala/src/module/xep/0199_ping.vala index a4157e99..35cad26c 100644 --- a/xmpp-vala/src/module/xep/0199_ping.vala +++ b/xmpp-vala/src/module/xep/0199_ping.vala @@ -9,20 +9,10 @@ namespace Xmpp.Xep.Ping { public const string ID = "0199_ping"; public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID); - public void send_ping(XmppStream stream, string jid, ResponseListener? listener = null) { + public void send_ping(XmppStream stream, string jid, ResponseListener listener) { Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("ping", NS_URI).add_self_xmlns()); iq.to = jid; - stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, listener == null? null : new IqResponseListenerImpl(listener)); - } - - private class IqResponseListenerImpl : Iq.ResponseListener, Object { - ResponseListener listener; - public IqResponseListenerImpl(ResponseListener listener) { - this.listener = listener; - } - public void on_result(XmppStream stream, Iq.Stanza iq) { - listener.on_result(stream); - } + stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, on_ping_response, listener); } public override void attach(XmppStream stream) { @@ -45,6 +35,11 @@ namespace Xmpp.Xep.Ping { } public void on_iq_set(XmppStream stream, Iq.Stanza iq) { } } + + private static void on_ping_response(XmppStream stream, Iq.Stanza iq, Object o) { + ResponseListener listener = o as ResponseListener; + listener.on_result(stream); + } } public interface ResponseListener : Object { |