Files
module-fastwebcore/target/fastweb/websocket.lua
2026-08-04 20:09:14 +08:00

83 lines
1.3 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
local M = {}
-- ws_type
M.UPGRADE = FW_WS_UPGRADE or 0
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
0 = UPGRADE
1 = MESSAGE_HEADER
2 = MESSAGE_BODY
3 = CLOSE
--]]
function M.type()
return fw_websocket:type()
end
--[[
FUNCTION 是否结束帧
--]]
function M.final()
return fw_websocket:final()
end
--[[
FUNCTION 取帧操作码
RETURN
0x0 连续帧
0x1 文本帧
0x2 二进制帧
0x8 连接关闭
0x9 ping
0xA pong
--]]
function M.opcode()
return fw_websocket:opcode()
end
--[[
FUNCTION 取载荷长度
--]]
function M.length()
return fw_websocket:length()
end
--[[
FUNCTION 取掩码 (4字节表下标1~4)
--]]
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