66 last_ack = new_ack; |
66 last_ack = new_ack; |
67 else |
67 else |
68 stream:warn("Received bad ack for "..new_ack.." when last ack was "..last_ack); |
68 stream:warn("Received bad ack for "..new_ack.." when last ack was "..last_ack); |
69 end |
69 end |
70 elseif stanza.name == "enabled" then |
70 elseif stanza.name == "enabled" then |
71 stream.smacks = true; |
|
72 |
|
73 -- Catch stanzas |
|
74 stream:hook("stanza", incoming_stanza); |
|
75 stream:hook("outgoing", outgoing_stanza); |
|
76 |
71 |
77 if stanza.attr.id then |
72 if stanza.attr.id then |
78 stream.resumption_token = stanza.attr.id; |
73 stream.resumption_token = stanza.attr.id; |
79 stream:hook("closed", on_close, 100); |
74 stream:hook("closed", on_close, 100); |
80 stream:hook("disconnected", on_disconnect, 100); |
75 stream:hook("disconnected", on_disconnect, 100); |
103 local function on_bind_success() |
98 local function on_bind_success() |
104 if not stream.smacks then |
99 if not stream.smacks then |
105 --stream:unhook("bind-success", on_bind_success); |
100 --stream:unhook("bind-success", on_bind_success); |
106 stream:debug("smacks: sending enable"); |
101 stream:debug("smacks: sending enable"); |
107 stream:send(verse.stanza("enable", { xmlns = xmlns_sm, resume = "true" })); |
102 stream:send(verse.stanza("enable", { xmlns = xmlns_sm, resume = "true" })); |
|
103 stream.smacks = true; |
|
104 |
|
105 -- Catch stanzas |
|
106 stream:hook("stanza", incoming_stanza); |
|
107 stream:hook("outgoing", outgoing_stanza); |
108 end |
108 end |
109 end |
109 end |
110 |
110 |
111 local function on_features(features) |
111 local function on_features(features) |
112 if features:get_child("sm", xmlns_sm) then |
112 if features:get_child("sm", xmlns_sm) then |