add message type

This commit is contained in:
zixun
2020-03-30 17:26:06 +08:00
committed by 云风
parent 7efa79906d
commit fd27676869
2 changed files with 4 additions and 3 deletions

View File

@@ -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

View File

@@ -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