mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-23 11:33:09 +00:00
Add traffic control for socket
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user