Comparison

net/xmppserver_listener.lua @ 2470:2c3f05c01d7c

net.xmppserver_listener: Extend session:close() with a remote_reason parameter
author Matthew Wild <mwild1@gmail.com>
date Tue, 19 Jan 2010 04:37:28 +0000
parent 2466:0e44b6035210
child 2471:2aeb55a51f47
comparison
equal deleted inserted replaced
2469:9e0c0b08f219 2470:2c3f05c01d7c
68 return true; 68 return true;
69 end 69 end
70 70
71 local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'}; 71 local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'};
72 local default_stream_attr = { ["xmlns:stream"] = "http://etherx.jabber.org/streams", xmlns = stream_callbacks.default_ns, version = "1.0", id = "" }; 72 local default_stream_attr = { ["xmlns:stream"] = "http://etherx.jabber.org/streams", xmlns = stream_callbacks.default_ns, version = "1.0", id = "" };
73 local function session_close(session, reason) 73 local function session_close(session, reason, remote_reason)
74 local log = session.log or log; 74 local log = session.log or log;
75 if session.conn then 75 if session.conn then
76 if session.notopen then 76 if session.notopen then
77 session.sends2s("<?xml version='1.0'?>"); 77 session.sends2s("<?xml version='1.0'?>");
78 session.sends2s(st.stanza("stream:stream", default_stream_attr):top_tag()); 78 session.sends2s(st.stanza("stream:stream", default_stream_attr):top_tag());
101 session.sends2s("</stream:stream>"); 101 session.sends2s("</stream:stream>");
102 if session.notopen or not session.conn:close() then 102 if session.notopen or not session.conn:close() then
103 session.conn:close(true); -- Force FIXME: timer? 103 session.conn:close(true); -- Force FIXME: timer?
104 end 104 end
105 session.conn:close(); 105 session.conn:close();
106 xmppserver.ondisconnect(session.conn, (reason and (reason.text or reason.condition)) or reason or "stream closed"); 106 xmppserver.ondisconnect(session.conn, remote_reason or (reason and (reason.text or reason.condition)) or reason or "stream closed");
107 end 107 end
108 end 108 end
109 109
110 110
111 -- End of session methods -- 111 -- End of session methods --