From 663fa798eeda2d1c66351d707c2f7e9cb2a9cf00 Mon Sep 17 00:00:00 2001 From: Thomas Harning Jr Date: Sat, 18 Aug 2007 20:57:33 +0000 Subject: * Committing what will be version 0.1.2 Main feature: Callback/coroutine issues resolved as described in COROUTINE_MANAGEMENT --- luaevent/test/test.lua | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'luaevent/test/test.lua') diff --git a/luaevent/test/test.lua b/luaevent/test/test.lua index fd9919d..412857e 100644 --- a/luaevent/test/test.lua +++ b/luaevent/test/test.lua @@ -5,20 +5,30 @@ require"luaevent" require"socket" -local function echoHandler(skt) - while true do - local data,ret = luaevent.receive(skt, 10) - if data == "quit" or ret == 'closed' or not data then - break - end - --collectgarbage() - if not luaevent.send(skt, data) then return end - end - if skt then skt:close() end +local oldPrint = print +print = function(...) + oldPrint("SRV", ...) end +local function echoHandler(skt) + while true do + local data,ret = luaevent.receive(skt, 10) + --print("GOT: ", data, ret) + if data == "quit" or ret == 'closed' then + break + end + luaevent.send(skt, data) + collectgarbage() + end + skt:close() + --print("DONE") +end local server = assert(socket.bind("localhost", 20000)) server:settimeout(0) - +local coro = coroutine.create +coroutine.create = function(...) + local ret = coro(...) + return ret +end luaevent.addserver(server, echoHandler) -luaevent.loop() \ No newline at end of file +luaevent.loop() -- cgit v1.2.3