mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
add message type
This commit is contained in:
@@ -21,7 +21,8 @@ if MODE == "agent" then
|
|||||||
print("--------------")
|
print("--------------")
|
||||||
end
|
end
|
||||||
|
|
||||||
function handle.message(id, msg)
|
function handle.message(id, msg, msg_type)
|
||||||
|
assert(msg_type == "binary" or msg_type == "text")
|
||||||
websocket.write(id, msg)
|
websocket.write(id, msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ local function resolve_accept(self)
|
|||||||
try_handle(self, "pong")
|
try_handle(self, "pong")
|
||||||
else
|
else
|
||||||
if fin and #recv_buf == 0 then
|
if fin and #recv_buf == 0 then
|
||||||
try_handle(self, "message", payload_data)
|
try_handle(self, "message", payload_data, op)
|
||||||
else
|
else
|
||||||
recv_buf[#recv_buf+1] = payload_data
|
recv_buf[#recv_buf+1] = payload_data
|
||||||
recv_count = recv_count + #payload_data
|
recv_count = recv_count + #payload_data
|
||||||
@@ -282,7 +282,7 @@ local function resolve_accept(self)
|
|||||||
end
|
end
|
||||||
if fin then
|
if fin then
|
||||||
local s = table.concat(recv_buf)
|
local s = table.concat(recv_buf)
|
||||||
try_handle(self, "message", s)
|
try_handle(self, "message", s, op)
|
||||||
recv_buf = {} -- clear recv_buf
|
recv_buf = {} -- clear recv_buf
|
||||||
recv_count = 0
|
recv_count = 0
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user