From 6955e472788acf9f4520661014a79687ef76ca04 Mon Sep 17 00:00:00 2001 From: Dev User Date: Tue, 4 Aug 2026 17:03:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0websocket?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- target/fastweb/websocket.lua | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 target/fastweb/websocket.lua diff --git a/target/fastweb/websocket.lua b/target/fastweb/websocket.lua new file mode 100644 index 0000000..8ae52f4 --- /dev/null +++ b/target/fastweb/websocket.lua @@ -0,0 +1,56 @@ +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 + +--[[ +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 + +return M