Browse Source

增加websocket

Dev User 1 month ago
parent
commit
6955e47278
1 changed files with 56 additions and 0 deletions
  1. 56 0
      target/fastweb/websocket.lua

+ 56 - 0
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