增加WEBSOCKET支持

This commit is contained in:
a158
2026-08-04 20:09:14 +08:00
parent 6955e47278
commit f440181f86
2 changed files with 60 additions and 0 deletions

View File

@@ -1,6 +1,40 @@
local M = {}
--[[
FUNCTION 发送响应头
PARAM
state_num 状态码
state_desc 状态描述
--]]
function M.send_header(state_num, state_desc)
return fw_response:send_header(state_num, state_desc)
end
--[[
FUNCTION 发送WebSocket数据
PARAM
data : 数据
opcode : 帧类型(可选默认文本12二进制 8关闭 9ping 10pong)
--]]
function M.send_ws(data, opcode)
return fw_response:send_ws(data, opcode or 1)
end
--[[
FUNCTION 响应结束
--]]
function M.response_done()
fw_response:response_done()
end
--[[
FUNCTION 是否已响应
--]]
function M.is_response_done()
return fw_response:is_response_done()
end
--[[
FUNCTION 发送字符串
PARAM

View File

@@ -6,6 +6,19 @@ M.MESSAGE_HEADER = FW_WS_MESSAGE_HEADER or 1
M.MESSAGE_BODY = FW_WS_MESSAGE_BODY or 2
M.CLOSE = FW_WS_CLOSE or 3
M.OPCODE_TEXT = FW_WS_OPCODE_TEXT or 1
M.OPCODE_BINARY = FW_WS_OPCODE_BINARY or 2
M.OPCODE_CLOSE = FW_WS_OPCODE_CLOSE or 8
M.OPCODE_PING = FW_WS_OPCODE_PING or 9
M.OPCODE_PONG = FW_WS_OPCODE_PONG or 10
--[[
FUNCTION 是否有效
--]]
function M.valid()
return fw_websocket:valid()
end
--[[
FUNCTION 取消息类型
RETURN
@@ -53,4 +66,17 @@ function M.mask()
return fw_websocket:mask()
end
--[[
FUNCTION 取Sec-WebSocket-Key
--]]
function M.sec_websocket_key()
return fw_websocket:sec_websocket_key()
end
--[[
FUNCTION 取连接ID
--]]
function M.connid()
return fw_websocket:connid()
end
return M