Add preconnect hook to lm.connect
authorMyhailo Danylenko <isbear@ukrpost.net>
Sun, 26 Jun 2011 19:59:28 +0300
changeset 36 41df6f2a7aa8
parent 35 5945cab29028
child 37 6e425a8e245e
Add preconnect hook to lm.connect To allow easy installation of log handler
lm.lua
--- a/lm.lua	Sun Jun 26 16:28:53 2011 +0300
+++ b/lm.lua	Sun Jun 26 19:59:28 2011 +0300
@@ -199,9 +199,10 @@
 end
 
 -- the same table, as for lm.connection.create, but with few more fields:
--- ssl.validate
--- onconnect
--- onopen
+-- ssl.validate - boolean
+-- preopen      - callback to call after connection creation but before opening (to install log handler, for example)
+-- onopen       - callback to call after connection is established, but before authentication
+-- onconnect    - callback to call after connection will be established
 -- username
 -- password
 -- resource
@@ -218,6 +219,9 @@
 		end
 	end
 	local c = lm.connection.create ( a )
+	if type ( a.preopen ) == "function" then
+		a.preopen ( c ) -- XXX
+	end
 	c:open (
 		function ( obj, status )
 			if status then
@@ -237,4 +241,4 @@
 
 return lm
 
--- vim: se ts=4: --
+-- vim: se ts=4 sw=4: --