scansion/objects/client.lua

changeset 60
e032cdb517ab
parent 53
3208dff3fb31
child 66
909c00296c2a
equal deleted inserted replaced
59:909305ae72ac 60:e032cdb517ab
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 ()

mercurial