summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Martin <flrgh@protonmail.com>2021-12-21 18:08:42 -0800
committerMichael Martin <flrgh@protonmail.com>2021-12-21 18:08:42 -0800
commit76c2905a77cf4b1e02e3ca82ee070768d9f7e5e5 (patch)
tree827c87f651bac8d6073f02e59480d0ff37c1b6e2
parentc43a93345bc4e8bda4adf5f686f17d4598094d78 (diff)
downloadlua-language-server-76c2905a77cf4b1e02e3ca82ee070768d9f7e5e5.zip
chore: update resty.websocket annotations
-rw-r--r--meta/3rd/OpenResty/library/resty.websocket.client.lua12
-rw-r--r--meta/3rd/OpenResty/library/resty.websocket.lua116
-rw-r--r--meta/3rd/OpenResty/library/resty.websocket.protocol.lua124
-rw-r--r--meta/3rd/OpenResty/library/resty.websocket.server.lua6
4 files changed, 128 insertions, 130 deletions
diff --git a/meta/3rd/OpenResty/library/resty.websocket.client.lua b/meta/3rd/OpenResty/library/resty.websocket.client.lua
index c722faf9..12615483 100644
--- a/meta/3rd/OpenResty/library/resty.websocket.client.lua
+++ b/meta/3rd/OpenResty/library/resty.websocket.client.lua
@@ -1,7 +1,7 @@
---@meta
---@class resty.websocket.client : resty.websocket
-resty_websocket_client = {
+local client = {
_VERSION = "0.09"
}
@@ -14,7 +14,7 @@ resty_websocket_client = {
---@param opts? resty.websocket.new.opts
---@return resty.websocket.client? client
---@return string? error
-function resty_websocket_client:new(opts) end
+function client:new(opts) end
---Connects to the remote WebSocket service port and performs the websocket
---handshake process on the client side.
@@ -27,7 +27,7 @@ function resty_websocket_client:new(opts) end
---@param opts? resty.websocket.client.connect.opts
---@return boolean ok
---@return string? error
-function resty_websocket_client:connect(uri, opts) end
+function client:connect(uri, opts) end
--- Puts the current WebSocket connection immediately into the ngx_lua cosocket connection pool.
---
@@ -41,7 +41,7 @@ function resty_websocket_client:connect(uri, opts) end
---@param pool_size integer
---@return boolean ok
---@return string? error
-function resty_websocket_client:set_keepalive(max_idle_timeout, pool_size) end
+function client:set_keepalive(max_idle_timeout, pool_size) end
---Closes the current WebSocket connection.
---
@@ -49,7 +49,7 @@ function resty_websocket_client:set_keepalive(max_idle_timeout, pool_size) end
---
---@return boolean ok
---@return string? error
-function resty_websocket_client:close() end
+function client:close() end
---@class resty.websocket.client.connect.opts : table
---
@@ -60,4 +60,4 @@ function resty_websocket_client:close() end
---@field headers string[] custom headers to be sent in the handshake request. The table is expected to contain strings in the format {"a-header: a header value", "another-header: another header value"}.
-return resty_websocket_client \ No newline at end of file
+return client \ No newline at end of file
diff --git a/meta/3rd/OpenResty/library/resty.websocket.lua b/meta/3rd/OpenResty/library/resty.websocket.lua
deleted file mode 100644
index 9ddd4921..00000000
--- a/meta/3rd/OpenResty/library/resty.websocket.lua
+++ /dev/null
@@ -1,116 +0,0 @@
----@meta
-
---- websocket object
---- https://github.com/openresty/lua-resty-websocket
----
----@class resty.websocket : table
----@field sock tcpsock
----@field fatal boolean
----@field max_payload_len number
----@field send_masked boolean
-resty_websocket = {}
-
----@param ms integer sets the timeout delay (in milliseconds) for the network-related operations
-function resty_websocket:set_timeout(ms) end
-
----Sends the text argument out as an unfragmented data frame of the text type.
----
----Returns the number of bytes that have actually been sent on the TCP level.
----
----In case of errors, returns nil and a string describing the error.
----
----@param text string
----@return integer? bytes
----@return string? error
-function resty_websocket:send_text(text) end
-
----Sends the data argument out as an unfragmented data frame of the binary type.
----
----Returns the number of bytes that have actually been sent on the TCP level.
----
----In case of errors, returns nil and a string describing the error.
----
----@param data string
----@return integer? bytes
----@return string? error
-function resty_websocket:send_binary(data) end
-
----Sends out a ping frame with an optional message specified by the msg argument.
----Returns the number of bytes that have actually been sent on the TCP level.
----
----In case of errors, returns nil and a string describing the error.
----
----Note that this method does not wait for a pong frame from the remote end.
----
----@param msg? string
----@return integer? bytes
----@return string? error
-function resty_websocket:send_ping(msg) end
-
----Sends out a pong frame with an optional message specified by the msg argument.
----Returns the number of bytes that have actually been sent on the TCP level.
----
----In case of errors, returns nil and a string describing the error.
----@param msg? string
----@return integer? bytes
----@return string? error
-function resty_websocket:send_pong(msg) end
-
----Sends out a close frame with an optional status code and a message.
----
----In case of errors, returns nil and a string describing the error.
----
----For a list of valid status code, see the following document:
----
----http://tools.ietf.org/html/rfc6455#section-7.4.1
----
----Note that this method does not wait for a close frame from the remote end.
----@param code? integer
----@param msg? string
----@return integer? bytes
----@return string? error
-function resty_websocket:send_close(code, msg) end
-
----Sends out a raw websocket frame by specifying the fin field (boolean value), the opcode, and the payload.
----
----For a list of valid opcode, see
----
----http://tools.ietf.org/html/rfc6455#section-5.2
----
----In case of errors, returns nil and a string describing the error.
----
----To control the maximal payload length allowed, you can pass the max_payload_len option to the new constructor.
----
----To control whether to send masked frames, you can pass true to the send_masked option in the new constructor method. By default, unmasked frames are sent.
----@param fin boolean
----@param opcode resty.websocket.protocol.opcode
----@param payload string
----@return integer? bytes
----@return string? error
-function resty_websocket:send_frame(fin, opcode, payload) end
-
----Receives a WebSocket frame from the wire.
----
----In case of an error, returns two nil values and a string describing the error.
----
----The second return value is always the frame type, which could be one of continuation, text, binary, close, ping, pong, or nil (for unknown types).
----
----For close frames, returns 3 values: the extra status message (which could be an empty string), the string "close", and a Lua number for the status code (if any). For possible closing status codes, see
----
----http://tools.ietf.org/html/rfc6455#section-7.4.1
----
----For other types of frames, just returns the payload and the type.
----
----For fragmented frames, the err return value is the Lua string "again".
----
----@return string? data
----@return resty.websocket.protocol.type? typ
----@return string|integer? error_or_status_code
-function resty_websocket:recv_frame() end
-
----@class resty.websocket.new.opts : table
----@field max_payload_len integer maximal length of payload allowed when sending and receiving WebSocket frames
----@field send_masked boolean whether to send out masked WebSocket frames
----@field timeout integer network timeout threshold in milliseconds
-
-return resty_websocket
diff --git a/meta/3rd/OpenResty/library/resty.websocket.protocol.lua b/meta/3rd/OpenResty/library/resty.websocket.protocol.lua
index c3455969..23591928 100644
--- a/meta/3rd/OpenResty/library/resty.websocket.protocol.lua
+++ b/meta/3rd/OpenResty/library/resty.websocket.protocol.lua
@@ -1,10 +1,124 @@
---@meta
---@class resty.websocket.protocol
-resty_websocket_protocol = {
+local protocol = {
_VERSION = "0.09",
}
+--- websocket object
+--- https://github.com/openresty/lua-resty-websocket
+---
+---@class resty.websocket : table
+---@field sock tcpsock
+---@field fatal boolean
+---@field max_payload_len number
+---@field send_masked boolean
+local websocket = {}
+
+---@param ms integer sets the timeout delay (in milliseconds) for the network-related operations
+function websocket:set_timeout(ms) end
+
+---Sends the text argument out as an unfragmented data frame of the text type.
+---
+---Returns the number of bytes that have actually been sent on the TCP level.
+---
+---In case of errors, returns nil and a string describing the error.
+---
+---@param text string
+---@return integer? bytes
+---@return string? error
+function websocket:send_text(text) end
+
+---Sends the data argument out as an unfragmented data frame of the binary type.
+---
+---Returns the number of bytes that have actually been sent on the TCP level.
+---
+---In case of errors, returns nil and a string describing the error.
+---
+---@param data string
+---@return integer? bytes
+---@return string? error
+function websocket:send_binary(data) end
+
+---Sends out a ping frame with an optional message specified by the msg argument.
+---Returns the number of bytes that have actually been sent on the TCP level.
+---
+---In case of errors, returns nil and a string describing the error.
+---
+---Note that this method does not wait for a pong frame from the remote end.
+---
+---@param msg? string
+---@return integer? bytes
+---@return string? error
+function websocket:send_ping(msg) end
+
+---Sends out a pong frame with an optional message specified by the msg argument.
+---Returns the number of bytes that have actually been sent on the TCP level.
+---
+---In case of errors, returns nil and a string describing the error.
+---@param msg? string
+---@return integer? bytes
+---@return string? error
+function websocket:send_pong(msg) end
+
+---Sends out a close frame with an optional status code and a message.
+---
+---In case of errors, returns nil and a string describing the error.
+---
+---For a list of valid status code, see the following document:
+---
+---http://tools.ietf.org/html/rfc6455#section-7.4.1
+---
+---Note that this method does not wait for a close frame from the remote end.
+---@param code? integer
+---@param msg? string
+---@return integer? bytes
+---@return string? error
+function websocket:send_close(code, msg) end
+
+---Sends out a raw websocket frame by specifying the fin field (boolean value), the opcode, and the payload.
+---
+---For a list of valid opcode, see
+---
+---http://tools.ietf.org/html/rfc6455#section-5.2
+---
+---In case of errors, returns nil and a string describing the error.
+---
+---To control the maximal payload length allowed, you can pass the max_payload_len option to the new constructor.
+---
+---To control whether to send masked frames, you can pass true to the send_masked option in the new constructor method. By default, unmasked frames are sent.
+---@param fin boolean
+---@param opcode resty.websocket.protocol.opcode
+---@param payload string
+---@return integer? bytes
+---@return string? error
+function websocket:send_frame(fin, opcode, payload) end
+
+---Receives a WebSocket frame from the wire.
+---
+---In case of an error, returns two nil values and a string describing the error.
+---
+---The second return value is always the frame type, which could be one of continuation, text, binary, close, ping, pong, or nil (for unknown types).
+---
+---For close frames, returns 3 values: the extra status message (which could be an empty string), the string "close", and a Lua number for the status code (if any). For possible closing status codes, see
+---
+---http://tools.ietf.org/html/rfc6455#section-7.4.1
+---
+---For other types of frames, just returns the payload and the type.
+---
+---For fragmented frames, the err return value is the Lua string "again".
+---
+---@return string? data
+---@return resty.websocket.protocol.type? typ
+---@return string|integer? error_or_status_code
+function websocket:recv_frame() end
+
+---@class resty.websocket.new.opts : table
+---@field max_payload_len integer maximal length of payload allowed when sending and receiving WebSocket frames
+---@field send_masked boolean whether to send out masked WebSocket frames
+---@field timeout integer network timeout threshold in milliseconds
+
+
--- Websocket op code
---
--- Defines the interpretation of the payload data.
@@ -34,7 +148,7 @@ resty_websocket_protocol = {
---@param payload string
---@param masking boolean
---@return string
-function resty_websocket_protocol.build_frame(fin, opcode, payload_len, payload, masking) end
+function protocol.build_frame(fin, opcode, payload_len, payload, masking) end
--- Sends a raw WebSocket frame.
---@param sock tcpsock
@@ -45,7 +159,7 @@ function resty_websocket_protocol.build_frame(fin, opcode, payload_len, payload,
---@param masking boolean
---@return bytes? number
---@return string? error
-function resty_websocket_protocol.send_frame(sock, fin, opcode, payload, max_payload_len, masking) end
+function protocol.send_frame(sock, fin, opcode, payload, max_payload_len, masking) end
--- Receives a WebSocket frame from the wire.
---@param sock tcpsock
@@ -54,6 +168,6 @@ function resty_websocket_protocol.send_frame(sock, fin, opcode, payload, max_pay
---@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
+function protocol.recv_frame(sock, max_payload_len, force_masking) end
-return resty_websocket_protocol \ No newline at end of file
+return protocol \ No newline at end of file
diff --git a/meta/3rd/OpenResty/library/resty.websocket.server.lua b/meta/3rd/OpenResty/library/resty.websocket.server.lua
index f590fcc8..c8f502a2 100644
--- a/meta/3rd/OpenResty/library/resty.websocket.server.lua
+++ b/meta/3rd/OpenResty/library/resty.websocket.server.lua
@@ -1,7 +1,7 @@
---@meta
---@class resty.websocket.server : resty.websocket
-resty_websocket_server = {
+local server = {
_VERSION = "0.09"
}
@@ -11,6 +11,6 @@ resty_websocket_server = {
---@param opts? resty.websocket.new.opts
---@return resty.websocket.server? server
---@return string? error
-function resty_websocket_server:new(opts) end
+function server:new(opts) end
-return resty_websocket_server \ No newline at end of file
+return server \ No newline at end of file