Comparison

mod_smacks/mod_smacks.lua @ 590:40b707d7a809

mod_smacks: Handle a client trying to <enable> twice, or trying to <enable> before resource binding (thanks Thijs Alkemade)
author Matthew Wild <mwild1@gmail.com>
date Wed, 01 Feb 2012 23:29:05 +0000
parent 589:57ac609444c4
child 591:36003cae2370
comparison
equal deleted inserted replaced
589:57ac609444c4 590:40b707d7a809
87 87
88 return session; 88 return session;
89 end 89 end
90 90
91 module:hook_stanza(xmlns_sm, "enable", function (session, stanza) 91 module:hook_stanza(xmlns_sm, "enable", function (session, stanza)
92 local err, err_text;
93 if session.smacks then
94 err, err_text = "unexpected-request", "Stream management already enabled for this stream";
95 elseif not session.resource then
96 err, err_text = "unexpected-request", "Attempted to enable stream management before resource binding";
97 end
98 if err then
99 session.log("warn", "Failed to enable smacks: %s", err_text); -- TODO: XEP doesn't say we can send error text, should it?
100 session.send(st.stanza("failed", { xmlns = xmlns_sm }):tag(err, { xmlns = xmlns_errors}));
101 return true;
102 end
103
92 module:log("debug", "Enabling stream management"); 104 module:log("debug", "Enabling stream management");
93 session.smacks = true; 105 session.smacks = true;
94 106
95 wrap_session(session); 107 wrap_session(session);
96 108