Software /
code /
prosody
Comparison
core/s2smanager.lua @ 5349:0d11e393201f
s2smanager: Use unused local, reduce table indexing
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 13 Mar 2013 07:33:36 +0100 |
parent | 5306:10bc0e2aa55e |
child | 5362:612467e263af |
comparison
equal
deleted
inserted
replaced
5348:ca0d820e9318 | 5349:0d11e393201f |
---|---|
10 | 10 |
11 local hosts = hosts; | 11 local hosts = hosts; |
12 local tostring, pairs, ipairs, getmetatable, newproxy, setmetatable | 12 local tostring, pairs, ipairs, getmetatable, newproxy, setmetatable |
13 = tostring, pairs, ipairs, getmetatable, newproxy, setmetatable; | 13 = tostring, pairs, ipairs, getmetatable, newproxy, setmetatable; |
14 | 14 |
15 local fire_event = prosody.events.fire_event; | |
16 local logger_init = require "util.logger".init; | 15 local logger_init = require "util.logger".init; |
17 | 16 |
18 local log = logger_init("s2smanager"); | 17 local log = logger_init("s2smanager"); |
19 | 18 |
20 local config = require "core.configmanager"; | 19 local config = require "core.configmanager"; |
21 | 20 |
22 local prosody = _G.prosody; | 21 local prosody = _G.prosody; |
23 incoming_s2s = {}; | 22 incoming_s2s = {}; |
24 prosody.incoming_s2s = incoming_s2s; | 23 prosody.incoming_s2s = incoming_s2s; |
25 local incoming_s2s = incoming_s2s; | 24 local incoming_s2s = incoming_s2s; |
25 local fire_event = prosody.events.fire_event; | |
26 | 26 |
27 module "s2smanager" | 27 module "s2smanager" |
28 | 28 |
29 local open_sessions = 0; | 29 local open_sessions = 0; |
30 | 30 |
89 | 89 |
90 session.log("info", "%s s2s connection %s->%s complete", session.direction, from, to); | 90 session.log("info", "%s s2s connection %s->%s complete", session.direction, from, to); |
91 | 91 |
92 local event_data = { session = session }; | 92 local event_data = { session = session }; |
93 if session.type == "s2sout" then | 93 if session.type == "s2sout" then |
94 prosody.events.fire_event("s2sout-established", event_data); | 94 fire_event("s2sout-established", event_data); |
95 hosts[from].events.fire_event("s2sout-established", event_data); | 95 hosts[from].events.fire_event("s2sout-established", event_data); |
96 else | 96 else |
97 local host_session = hosts[to]; | 97 local host_session = hosts[to]; |
98 session.send = function(stanza) | 98 session.send = function(stanza) |
99 return host_session.events.fire_event("route/remote", { from_host = to, to_host = from, stanza = stanza }); | 99 return host_session.events.fire_event("route/remote", { from_host = to, to_host = from, stanza = stanza }); |
100 end; | 100 end; |
101 | 101 |
102 prosody.events.fire_event("s2sin-established", event_data); | 102 fire_event("s2sin-established", event_data); |
103 hosts[to].events.fire_event("s2sin-established", event_data); | 103 hosts[to].events.fire_event("s2sin-established", event_data); |
104 end | 104 end |
105 | 105 |
106 if session.direction == "outgoing" then | 106 if session.direction == "outgoing" then |
107 if sendq then | 107 if sendq then |
156 incoming_s2s[session] = nil; | 156 incoming_s2s[session] = nil; |
157 end | 157 end |
158 | 158 |
159 local event_data = { session = session, reason = reason }; | 159 local event_data = { session = session, reason = reason }; |
160 if session.type == "s2sout" then | 160 if session.type == "s2sout" then |
161 prosody.events.fire_event("s2sout-destroyed", event_data); | 161 fire_event("s2sout-destroyed", event_data); |
162 if hosts[session.from_host] then | 162 if hosts[session.from_host] then |
163 hosts[session.from_host].events.fire_event("s2sout-destroyed", event_data); | 163 hosts[session.from_host].events.fire_event("s2sout-destroyed", event_data); |
164 end | 164 end |
165 elseif session.type == "s2sin" then | 165 elseif session.type == "s2sin" then |
166 prosody.events.fire_event("s2sin-destroyed", event_data); | 166 fire_event("s2sin-destroyed", event_data); |
167 if hosts[session.to_host] then | 167 if hosts[session.to_host] then |
168 hosts[session.to_host].events.fire_event("s2sin-destroyed", event_data); | 168 hosts[session.to_host].events.fire_event("s2sin-destroyed", event_data); |
169 end | 169 end |
170 end | 170 end |
171 | 171 |