Add traffic control for socket

This commit is contained in:
Cloud Wu
2020-09-04 12:26:13 +08:00
parent 55efa75fdf
commit 280f0251da
2 changed files with 21 additions and 7 deletions

View File

@@ -5,6 +5,7 @@ local mode , id = ...
local function echo(id)
socket.start(id)
socket.write(id, "Hello Skynet\n")
while true do
local str = socket.read(id)
@@ -28,12 +29,7 @@ if mode == "agent" then
end)
else
local function accept(id)
socket.start(id)
socket.write(id, "Hello Skynet\n")
skynet.newservice(SERVICE_NAME, "agent", id)
-- notice: Some data on this connection(id) may lost before new service start.
-- So, be careful when you want to use start / abandon / start .
socket.abandon(id)
end
skynet.start(function()