Software /
code /
prosody
Comparison
util/xmppstream.lua @ 3424:9e0df614e5d0
util.xmppstream: Add set_session() method to change the session that a stream is associated with
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 02 Aug 2010 10:21:26 +0100 |
parent | 3032:38459cffaf67 |
child | 3444:e6a78e15fed2 |
comparison
equal
deleted
inserted
replaced
3423:929fb7b65d2c | 3424:9e0df614e5d0 |
---|---|
143 | 143 |
144 local function reset() | 144 local function reset() |
145 stanza, chardata = nil, {}; | 145 stanza, chardata = nil, {}; |
146 end | 146 end |
147 | 147 |
148 return xml_handlers, { reset = reset }; | 148 local function set_session(stream, new_session) |
149 session = new_session; | |
150 log = new_session.log or default_log; | |
151 end | |
152 | |
153 return xml_handlers, { reset = reset, set_session = set_session }; | |
149 end | 154 end |
150 | 155 |
151 function new(session, stream_callbacks) | 156 function new(session, stream_callbacks) |
152 local handlers, meta = new_sax_handlers(session, stream_callbacks); | 157 local handlers, meta = new_sax_handlers(session, stream_callbacks); |
153 local parser = new_parser(handlers, ns_separator); | 158 local parser = new_parser(handlers, ns_separator); |
159 parse = parser.parse; | 164 parse = parser.parse; |
160 meta.reset(); | 165 meta.reset(); |
161 end, | 166 end, |
162 feed = function (self, data) | 167 feed = function (self, data) |
163 return parse(parser, data); | 168 return parse(parser, data); |
164 end | 169 end, |
170 set_session = meta.set_session; | |
165 }; | 171 }; |
166 end | 172 end |
167 | 173 |
168 return _M; | 174 return _M; |