Mercurial > prosody-modules
comparison mod_bidi/mod_bidi.lua @ 1122:6094d57c5387
mod_bidi: Minor cleanup
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 02 Aug 2013 18:21:14 +0200 |
parents | c714ed7de4ee |
children | 0e16e5e2f410 |
comparison
equal
deleted
inserted
replaced
1121:c714ed7de4ee | 1122:6094d57c5387 |
---|---|
29 if origin.type == "s2sin" then -- then we create an "outgoing" bidirectional session | 29 if origin.type == "s2sin" then -- then we create an "outgoing" bidirectional session |
30 local conflicting_session = hosts[origin.to_host].s2sout[origin.from_host] | 30 local conflicting_session = hosts[origin.to_host].s2sout[origin.from_host] |
31 if conflicting_session then | 31 if conflicting_session then |
32 conflicting_session.log("info", "We already have an outgoing connection to %s, closing it...", origin.from_host); | 32 conflicting_session.log("info", "We already have an outgoing connection to %s, closing it...", origin.from_host); |
33 conflicting_session:close{ condition = "conflict", text = "Replaced by bidirectional stream" } | 33 conflicting_session:close{ condition = "conflict", text = "Replaced by bidirectional stream" } |
34 s2smanager.destroy_session(conflicting_session); | |
35 end | 34 end |
36 bidi_sessions[origin.from_host] = origin; | 35 bidi_sessions[origin.from_host] = origin; |
37 elseif origin.type == "s2sout" then -- handle incoming stanzas correctly | 36 elseif origin.type == "s2sout" then -- handle incoming stanzas correctly |
38 local bidi_session = { | 37 local bidi_session = { |
39 type = "s2sin"; | 38 type = "s2sin"; |
103 module:hook("s2sin-established", enable_bidi); | 102 module:hook("s2sin-established", enable_bidi); |
104 module:hook("s2sout-established", enable_bidi); | 103 module:hook("s2sout-established", enable_bidi); |
105 | 104 |
106 function disable_bidi(event) | 105 function disable_bidi(event) |
107 local session = event.session; | 106 local session = event.session; |
108 if session.type == "s2sin" then -- then we create an "outgoing" bidirectional session | 107 if session.type == "s2sin" then |
109 bidi_sessions[session.from_host] = nil; | 108 bidi_sessions[session.from_host] = nil; |
110 end | 109 end |
111 end | 110 end |
112 | 111 |
113 module:hook("s2sin-destroyed", disable_bidi); | 112 module:hook("s2sin-destroyed", disable_bidi); |