Software /
code /
verse
Comparison
plugins/smacks.lua @ 197:7e98cf2c1d8d
plugins.*: Use verse.stanza() & co instead of require util.stanza
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 17 Mar 2011 18:33:52 +0100 |
parent | 188:4678932455a3 |
child | 200:4166213cc9bd |
comparison
equal
deleted
inserted
replaced
196:eb9d69d3f0b5 | 197:7e98cf2c1d8d |
---|---|
1 local st = require "util.stanza"; | |
2 | |
3 local xmlns_sm = "urn:xmpp:sm:2"; | 1 local xmlns_sm = "urn:xmpp:sm:2"; |
4 | 2 |
5 function verse.plugins.smacks(stream) | 3 function verse.plugins.smacks(stream) |
6 -- State for outgoing stanzas | 4 -- State for outgoing stanzas |
7 local outgoing_queue = {}; | 5 local outgoing_queue = {}; |
73 end | 71 end |
74 | 72 |
75 local function on_bind_success() | 73 local function on_bind_success() |
76 if not stream.smacks then | 74 if not stream.smacks then |
77 --stream:unhook("bind-success", on_bind_success); | 75 --stream:unhook("bind-success", on_bind_success); |
78 stream:send(st.stanza("enable", { xmlns = xmlns_sm, resume = "true" })); | 76 stream:send(verse.stanza("enable", { xmlns = xmlns_sm, resume = "true" })); |
79 end | 77 end |
80 end | 78 end |
81 | 79 |
82 local function on_features(features) | 80 local function on_features(features) |
83 if features:get_child("sm", xmlns_sm) then | 81 if features:get_child("sm", xmlns_sm) then |
84 stream.stream_management_supported = true; | 82 stream.stream_management_supported = true; |
85 if stream.smacks and stream.bound then -- Already enabled in a previous session - resume | 83 if stream.smacks and stream.bound then -- Already enabled in a previous session - resume |
86 stream:send(st.stanza("resume", { xmlns = xmlns_sm, | 84 stream:send(verse.stanza("resume", { xmlns = xmlns_sm, |
87 h = handled_stanza_count, previd = stream.resumption_token })); | 85 h = handled_stanza_count, previd = stream.resumption_token })); |
88 else | 86 else |
89 stream:hook("bind-success", on_bind_success); | 87 stream:hook("bind-success", on_bind_success); |
90 end | 88 end |
91 return true; | 89 return true; |