WebSocket¶
-
class
WebSocket
¶ -
id
: number or str¶
-
url
: str¶ the endpoint to hit
-
socket
: table¶ lua socket
-
handshake_key
: str¶ key used in the websocket handshake
-
config
: Config¶
-
handshake
: Handshake¶
-
_send_tx
: table¶
-
_send_rx
: table¶
-
_recv_tx
: table¶
-
_recv_rx
: table¶
-
is_client
: boolean¶
-
static
client
(socket, url, config)¶ Create new client object
-
static
server
(socket, config)¶ Create a server side websocket (NOT YET IMPLEMENTED)
-
send_text
(text)¶ - Parameters
text (str) –
- Return type
number or str or nil
-
send_bytes
(bytes)¶ - Parameters
bytes (str) –
- Return type
number
- Return type
number or str or nil
-
connect
()¶ - Return type
number or str or nil
-
accept
()¶
-
close
(close_code, reason)¶ - Parameters
close_code (CloseCode) –
reason (str) –
- Returns
1 if success
- Return type
number
- Return type
str or nil
-
setwaker
(kind, waker)¶ Cosock internal interface for using cosock.socket.select
- Parameters
kind (str) –
waker (fun()) –
-
_handle_recvs
(state, recv, idx)¶ - Parameters
state (any) –
recv (any) –
idx (any) –
-
_handle_select_err
(state, err)¶ - Parameters
state (any) –
err (any) –
-
_handle_recv_ready
(state)¶ - Parameters
state (any) –
-
_handle_recv_control_frame
(frame, state)¶ - Parameters
frame (any) –
state (any) –
-
_handle_send_ready
()¶
-
_handle_sent_close_frame
()¶
-
_handle_recvd_close_frame
()¶
-