Changeset

10278:94c584d67533

net.server_epoll: Make it easy to override handler for incoming data
author Kim Alvefur <zash@zash.se>
date Sun, 29 Sep 2019 14:50:04 +0200
parents 10277:45a58127a3e5
children 10279:0e1701197722
files net/server_epoll.lua
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/net/server_epoll.lua	Sat Sep 28 22:59:29 2019 +0200
+++ b/net/server_epoll.lua	Sun Sep 29 14:50:04 2019 +0200
@@ -189,6 +189,11 @@
 	return err;
 end
 
+-- Allow this one to be overridden
+function interface:onincoming(...)
+	return self:on("incoming", ...);
+end
+
 -- Return the file descriptor number
 function interface:getfd()
 	if self.conn then
@@ -360,7 +365,7 @@
 	local data, err, partial = self.conn:receive(self.read_size or cfg.read_size);
 	if data then
 		self:onconnect();
-		self:on("incoming", data);
+		self:onincoming(data);
 	else
 		if err == "wantread" then
 			self:set(true, nil);
@@ -371,7 +376,7 @@
 		end
 		if partial and partial ~= "" then
 			self:onconnect();
-			self:on("incoming", partial, err);
+			self:onincoming(partial, err);
 		end
 		if err ~= "timeout" then
 			self:on("disconnect", err);