verse: Change to set conn:send in only one place, and fire new events 'outgoing' and 'outgoing-raw'

Wed, 15 Dec 2010 14:48:55 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 15 Dec 2010 14:48:55 +0000
changeset 163
48a47bca9a63
parent 162
2950079d4319
child 164
d862093d9f91

verse: Change to set conn:send in only one place, and fire new events 'outgoing' and 'outgoing-raw'

init.lua file | annotate | diff | comparison | revisions
--- a/init.lua	Wed Dec 15 11:57:23 2010 +0000
+++ b/init.lua	Wed Dec 15 14:48:55 2010 +0000
@@ -89,8 +89,12 @@
 	end
 	
 	self.conn = conn;
-	local w, t = conn.write, tostring;
-	self.send = function (_, data) return w(conn, t(data)); end
+	self.send = function (stream, data)
+		self:event("outgoing", data);
+		data = tostring(data);
+		self:event("outgoing-raw", data);
+		return conn:write(data);
+	end;
 	return true;
 end
 
@@ -186,7 +190,6 @@
 	
 	function conn_listener.onconnect(conn)
 		stream.connected = true;
-		stream.send = function (stream, data) stream:debug("Sending data: "..tostring(data)); return conn:write(tostring(data)); end;
 		stream:event("connected");
 	end
 	

mercurial