comparison mod_smacks/mod_smacks.lua @ 1529:16893646a458

mod_smacks: Move wrap_session() contents into separate direction-specific routines
author Kim Alvefur <zash@zash.se>
date Mon, 20 Oct 2014 13:13:48 +0200
parents 5ccb3ee2cf72
children fb7cd669f41b
comparison
equal deleted inserted replaced
1528:5ccb3ee2cf72 1529:16893646a458
103 session.log("debug", "Handled %d incoming stanzas", session.handled_stanza_count); 103 session.log("debug", "Handled %d incoming stanzas", session.handled_stanza_count);
104 end 104 end
105 return stanza; 105 return stanza;
106 end 106 end
107 107
108 local function wrap_session(session, resume) 108 local function wrap_session_out(session, resume)
109 if not resume then 109 if not resume then
110 session.outgoing_stanza_queue = {}; 110 session.outgoing_stanza_queue = {};
111 session.last_acknowledged_stanza = 0; 111 session.last_acknowledged_stanza = 0;
112 end 112 end
113 113
119 session_registry[session.resumption_token] = nil; 119 session_registry[session.resumption_token] = nil;
120 session.resumption_token = nil; 120 session.resumption_token = nil;
121 end 121 end
122 return session_close(...); 122 return session_close(...);
123 end 123 end
124 124 return session;
125 end
126
127 local function wrap_session_in(session, resume)
125 if not resume then 128 if not resume then
126 session.handled_stanza_count = 0; 129 session.handled_stanza_count = 0;
127 add_filter(session, "stanzas/in", count_incoming_stanzas, 1000); 130 add_filter(session, "stanzas/in", count_incoming_stanzas, 1000);
128 end 131 end
129 132
133 return session;
134 end
135
136 local function wrap_session(session, resume)
137 wrap_session_out(session, resume);
138 wrap_session_in(session, resume);
130 return session; 139 return session;
131 end 140 end
132 141
133 function handle_enable(session, stanza, xmlns_sm) 142 function handle_enable(session, stanza, xmlns_sm)
134 local ok, err, err_text = can_do_smacks(session); 143 local ok, err, err_text = can_do_smacks(session);