equal
deleted
inserted
replaced
9 -- public |
9 -- public |
10 |
10 |
11 ping = { } |
11 ping = { } |
12 |
12 |
13 function ping.send ( conn, to, success, fail ) |
13 function ping.send ( conn, to, success, fail ) |
14 iq.send ( conn, to, 'get', success, fail ) |
14 iq.send ( conn, to, 'get', |
|
15 { |
|
16 ping = { xmlns = 'urn:xmpp:ping' }, |
|
17 }, success, fail ) |
15 end |
18 end |
16 |
19 |
17 -- private |
20 -- private |
18 |
21 |
19 local ping_incoming_iq_handler = lm.message_handler.new ( |
22 local ping_incoming_iq_handler = lm.message_handler.new ( |
40 who = main.full_jid () |
43 who = main.full_jid () |
41 end |
44 end |
42 local time = os.time () |
45 local time = os.time () |
43 ping.send ( lm.connection.bless ( main.connection () ), who, |
46 ping.send ( lm.connection.bless ( main.connection () ), who, |
44 function () |
47 function () |
45 main.print_info ( ('Pong: %d seconds'):format ( os.time () - time ) ) |
48 main.print_info ( who, ('Pong: %d seconds'):format ( os.time () - time ) ) |
46 end, |
49 end, |
47 function ( mesg ) |
50 function ( mesg ) |
48 main.print_info ( 'Ping failed: ' .. mesg ) |
51 main.print_info ( who, 'Ping failed: ' .. mesg ) |
49 end ) |
52 end ) |
50 end, true, 'jid' ) |
53 end, true, 'jid' ) |
51 |
54 |
|
55 --[[ |
52 local ping_handler_registered = false |
56 local ping_handler_registered = false |
53 |
57 |
54 hooks_d['hook-post-connect'].ping = |
58 hooks_d['hook-post-connect'].ping = |
55 function ( args ) |
59 function ( args ) |
56 lm.connection.bless( main.connection () ):handler ( ping_incoming_iq_handler, 'iq', 'normal' ) |
60 lm.connection.bless( main.connection () ):handler ( ping_incoming_iq_handler, 'iq', 'normal' ) |
63 end |
67 end |
64 end |
68 end |
65 end |
69 end |
66 |
70 |
67 main.add_feature ( 'urn:xmpp:ping' ) |
71 main.add_feature ( 'urn:xmpp:ping' ) |
|
72 --]] |
68 |
73 |
69 -- vim: se ts=4: -- |
74 -- vim: se ts=4: -- |