Changeset

3001:fa00c6f563b4

net.server_select, net.server_event: Rename :pattern() method to :set_mode() for select backend, and add :set_mode() to event backend
author Matthew Wild <mwild1@gmail.com>
date Wed, 05 May 2010 15:23:17 +0100
parents 3000:43a4cb707fe4
children 3002:d1f864ed44c0
files net/server_event.lua net/server_select.lua
diffstat 2 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/net/server_event.lua	Wed May 05 15:21:17 2010 +0100
+++ b/net/server_event.lua	Wed May 05 15:23:17 2010 +0100
@@ -402,6 +402,13 @@
 			self.starttls = false; -- prevent starttls()
 		end
 	end
+
+	function interface_mt:set_mode(pattern)
+		if pattern then
+			self._pattern = pattern;
+		end
+		return self._pattern;
+	end
 	
 	function interface_mt:set_send(new_send)
 		-- No-op, we always use the underlying connection's send
@@ -599,7 +606,7 @@
 						interface.eventreadtimeout = nil
 					end
 				end
-				local buffer, err, part = interface.conn:receive( pattern )  -- receive buffer with "pattern"
+				local buffer, err, part = interface.conn:receive( interface._pattern )  -- receive buffer with "pattern"
 				--vdebug( "read data:", tostring(buffer), "error:", tostring(err), "part:", tostring(part) )
 				buffer = buffer or part or ""
 				local len = string_len( buffer )
--- a/net/server_select.lua	Wed May 05 15:21:17 2010 +0100
+++ b/net/server_select.lua	Wed May 05 15:23:17 2010 +0100
@@ -379,7 +379,7 @@
 	handler.socket = function( self )
 		return socket
 	end
-	handler.pattern = function( self, new )
+	handler.set_mode = function( self, new )
 		pattern = new or pattern
 		return pattern
 	end