Software /
code /
prosody
Comparison
plugins/mod_bosh.lua @ 11868:ae093c259da2
mod_c2s,etc: Identify stanza object with appropriate function
Better than duck typing, in case anyone ever passes a non-stanza table
with a 'name' field.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 24 Oct 2021 15:17:01 +0200 |
parent | 11808:c24580a214f3 |
child | 12262:50525021c2c7 |
comparison
equal
deleted
inserted
replaced
11867:bb20cfd4884f | 11868:ae093c259da2 |
---|---|
234 if reason then | 234 if reason then |
235 close_reply.attr.condition = "remote-stream-error"; | 235 close_reply.attr.condition = "remote-stream-error"; |
236 if type(reason) == "string" then -- assume stream error | 236 if type(reason) == "string" then -- assume stream error |
237 close_reply:tag("stream:error") | 237 close_reply:tag("stream:error") |
238 :tag(reason, {xmlns = xmlns_xmpp_streams}); | 238 :tag(reason, {xmlns = xmlns_xmpp_streams}); |
239 elseif st.is_stanza(reason) then | |
240 close_reply = reason; | |
239 elseif type(reason) == "table" then | 241 elseif type(reason) == "table" then |
240 if reason.condition then | 242 if reason.condition then |
241 close_reply:tag("stream:error") | 243 close_reply:tag("stream:error") |
242 :tag(reason.condition, stream_xmlns_attr):up(); | 244 :tag(reason.condition, stream_xmlns_attr):up(); |
243 if reason.text then | 245 if reason.text then |
244 close_reply:tag("text", stream_xmlns_attr):text(reason.text):up(); | 246 close_reply:tag("text", stream_xmlns_attr):text(reason.text):up(); |
245 end | 247 end |
246 if reason.extra then | 248 if reason.extra then |
247 close_reply:add_child(reason.extra); | 249 close_reply:add_child(reason.extra); |
248 end | 250 end |
249 elseif reason.name then -- a stanza | |
250 close_reply = reason; | |
251 end | 251 end |
252 end | 252 end |
253 log("info", "Disconnecting client, <stream:error> is: %s", close_reply); | 253 log("info", "Disconnecting client, <stream:error> is: %s", close_reply); |
254 end | 254 end |
255 | 255 |