changeset 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
files mod_smacks/mod_smacks.lua
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_smacks/mod_smacks.lua	Mon Oct 20 13:11:28 2014 +0200
+++ b/mod_smacks/mod_smacks.lua	Mon Oct 20 13:13:48 2014 +0200
@@ -105,7 +105,7 @@
 	return stanza;
 end
 
-local function wrap_session(session, resume)
+local function wrap_session_out(session, resume)
 	if not resume then
 		session.outgoing_stanza_queue = {};
 		session.last_acknowledged_stanza = 0;
@@ -121,7 +121,10 @@
 		end
 		return session_close(...);
 	end
+	return session;
+end
 
+local function wrap_session_in(session, resume)
 	if not resume then
 		session.handled_stanza_count = 0;
 		add_filter(session, "stanzas/in", count_incoming_stanzas, 1000);
@@ -130,6 +133,12 @@
 	return session;
 end
 
+local function wrap_session(session, resume)
+	wrap_session_out(session, resume);
+	wrap_session_in(session, resume);
+	return session;
+end
+
 function handle_enable(session, stanza, xmlns_sm)
 	local ok, err, err_text = can_do_smacks(session);
 	if not ok then