Software /
code /
prosody
Comparison
net/xmppcomponent_listener.lua @ 2129:fcdcdf00787c
*_listener: Update for new net.server API, specifically .listener -> .onincoming, .disconnect -> .ondisconnect
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 22 Nov 2009 04:43:46 +0000 |
parent | 2077:e33658f6052c |
child | 2135:2119a5d603d8 |
comparison
equal
deleted
inserted
replaced
2128:f107f0205793 | 2129:fcdcdf00787c |
---|---|
116 end | 116 end |
117 end | 117 end |
118 end | 118 end |
119 session.send("</stream:stream>"); | 119 session.send("</stream:stream>"); |
120 session.conn.close(); | 120 session.conn.close(); |
121 component_listener.disconnect(session.conn, "stream error"); | 121 component_listener.ondisconnect(session.conn, "stream error"); |
122 end | 122 end |
123 end | 123 end |
124 | 124 |
125 --- Component connlistener | 125 --- Component connlistener |
126 function component_listener.listener(conn, data) | 126 function component_listener.onincoming(conn, data) |
127 local session = sessions[conn]; | 127 local session = sessions[conn]; |
128 if not session then | 128 if not session then |
129 local _send = conn.write; | 129 local _send = conn.write; |
130 session = { type = "component", conn = conn, send = function (data) return _send(tostring(data)); end }; | 130 session = { type = "component", conn = conn, send = function (data) return _send(tostring(data)); end }; |
131 sessions[conn] = session; | 131 sessions[conn] = session; |
155 if data then | 155 if data then |
156 session.data(conn, data); | 156 session.data(conn, data); |
157 end | 157 end |
158 end | 158 end |
159 | 159 |
160 function component_listener.disconnect(conn, err) | 160 function component_listener.ondisconnect(conn, err) |
161 local session = sessions[conn]; | 161 local session = sessions[conn]; |
162 if session then | 162 if session then |
163 (session.log or log)("info", "component disconnected: %s (%s)", tostring(session.host), tostring(err)); | 163 (session.log or log)("info", "component disconnected: %s (%s)", tostring(session.host), tostring(err)); |
164 if session.host then | 164 if session.host then |
165 log("debug", "Deregistering component"); | 165 log("debug", "Deregistering component"); |