summaryrefslogtreecommitdiff
path: root/meta/3rd/OpenResty/library/resty.websocket.protocol.lua
blob: c3455969ad7133792f8a9670037bd83f42880f97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
---@meta

---@class resty.websocket.protocol
resty_websocket_protocol = {
  _VERSION = "0.09",
}

--- Websocket op code
---
--- Defines the interpretation of the payload data.
---
--- See RFC 6455 section 5.2
---
---@alias resty.websocket.protocol.opcode
---| '0x0' # continuation
---| '0x1' # text
---| '0x2' # binary
---| '0x8' # close
---| '0x9' # ping
---| '0xa' # pong

---@alias resty.websocket.protocol.type
---| '"continuation"'
---| '"text"'
---| '"binary"'
---| '"close"'
---| '"ping"'
---| '"pong"'

--- Builds a raw WebSocket frame.
---@param  fin         boolean
---@param  opcode      resty.websocket.protocol.opcode
---@param  payload_len integer
---@param  payload     string
---@param  masking     boolean
---@return string
function resty_websocket_protocol.build_frame(fin, opcode, payload_len, payload, masking) end

--- Sends a raw WebSocket frame.
---@param  sock            tcpsock
---@param  fin             boolean
---@param  opcode          resty.websocket.protocol.opcode
---@param  payload         string
---@param  max_payload_len interger
---@param  masking         boolean
---@return bytes?          number
---@return string?         error
function resty_websocket_protocol.send_frame(sock, fin, opcode, payload, max_payload_len, masking) end

--- Receives a WebSocket frame from the wire.
---@param  sock                           tcpsock
---@param  max_payload_len                interger
---@param  force_masking                  boolean
---@return string?                        data
---@return resty.websocket.protocol.type? typ
---@return string?                        error
function resty_websocket_protocol.recv_frame(sock, max_payload_len, force_masking) end

return resty_websocket_protocol