47 -- This one prints all received data |
47 -- This one prints all received data |
48 client.stream:hook("incoming-raw", function (s) client.log("Data in: %s", s); end, 1000); |
48 client.stream:hook("incoming-raw", function (s) client.log("Data in: %s", s); end, 1000); |
49 client.stream:hook("outgoing-raw", function (s) client.log("Data out: %s", s); end, 1000); |
49 client.stream:hook("outgoing-raw", function (s) client.log("Data out: %s", s); end, 1000); |
50 -- And incoming, parsed, stanzas |
50 -- And incoming, parsed, stanzas |
51 client.stream:hook("stanza", function (s) client.log("Stanza: %s", s) end); |
51 client.stream:hook("stanza", function (s) client.log("Stanza: %s", s) end); |
|
52 -- Handle unexpected disconnects |
|
53 client.stream:hook("disconnected", function (s) |
|
54 client.log("Unexpected disconnect!"); |
|
55 error("Unexpected disconnect"); |
|
56 end); |
52 end; |
57 end; |
53 |
58 |
54 connects = function (client) |
59 connects = function (client) |
55 local wait, done = async.waiter(); |
60 local wait, done = async.waiter(); |
56 client.stream:hook("ready", function () |
61 client.stream:hook("ready", function () |