Diff

net/server_select.lua @ 2970:9b8e139eff5f

net.server_select: Support for listener.onconnect
author Matthew Wild <mwild1@gmail.com>
date Sun, 11 Apr 2010 01:11:42 +0100
parent 2968:fdd049a4e551
child 2998:36c169ed1576
child 3000:43a4cb707fe4
line wrap: on
line diff
--- a/net/server_select.lua	Fri Apr 09 12:31:51 2010 +0100
+++ b/net/server_select.lua	Sun Apr 11 01:11:42 2010 +0100
@@ -611,7 +611,16 @@
 
 	_socketlist[ socket ] = handler
 	_readlistlen = addsocket(_readlist, socket, _readlistlen)
-
+	if listeners.onconnect then
+		_sendlistlen = addsocket(_sendlist, socket, _sendlistlen)
+		handler.sendbuffer = function ()
+			listeners.onconnect(handler);
+			handler.sendbuffer = _sendbuffer;
+			if bufferqueuelen > 0 then
+				return _senddbuffer();
+			end
+		end
+	end
 	return handler, socket
 end