-
Notifications
You must be signed in to change notification settings - Fork 16
/
ws.node_cli.txt
116 lines (97 loc) · 6.41 KB
/
ws.node_cli.txt
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
WS
VERSION ==> #0.4.32
/=+===============================+=\
/ : : \
)==: CLIENT :==(
\ :_______________________________: /
\=+===============================+=/
new WS(WS[S]_URL[, OBJ]) #Returns WSOCKET
#OBJ (for upgrade request):
# - protocol SUBPROTOCOL
# - origin STR
# - protocolVersion STR: "8", "13" (def) or "hixie-76"
# - agent AGENT
# - host STR
# - pfx, key, cert, passphrase, ca, crl, ciphers: passed to CRYPTO.createCredentials()
# - rejectUnauthorized BOOL: like TLS.createServer()
WSOCKET.on
("open", FUNC()) #
WSOCKET.on
("close", FUNC(UINT, STR)) #
WSOCKET.readyState #WS.CONNECTING|OPEN|CLOSING|CLOSED
WSOCKET.close
([UINT, ][STR]) #
WSOCKET.terminate() #Immediately close (still emit close event)
WSOCKET.on("error",FUNC(EROR))#
WSOCKET.pause|resume() #Listening, not sending
WSOCKET.send(STR|BUFFER[,OBJ] #OBJ:
[, FUNC(ERROR)]) # - binary BOOL: true if TDBUFFER
# - mask BOOL: use masked bit
#If no FUNC(ERROR), throw ERROR
WSOCKET.ping|pong
([STR|BUFFER[, OBJ],][BOOL]) #If false, throws if connection closed
WSOCKT.on("message|ping|pong",
FUNC(STR|BUFFER, OBJ)) #OBJ: same as send(), but using masked, not mask
WSOCKET.protocol #SUBPROTOCOL
WSOCKET.url #Not WSOCKETSERVER's WSOCKET
WSOCKET.bytesReceived #So far. UINT
WSOCKET.protocolVersion #
WSOCKET.supports #{ binary: BOOL }
/=+===============================+=\
/ : : \
)==: SERVER :==(
\ :_______________________________: /
\=+===============================+=/
new WS.Server(OBJ[, FUNC()]) #Returns WSOCKETSERVER, an HTTP[S].SERVER which returns 200 "Not implemented" on HTTP[S] requests
#and handle upgrade requests to Websocket. OBJ:
# - host, path, port
# - server HTTP[S].SERVER: use handleUpgrade() on HTTP[S].SERVER upgrade event handler instead.
# - noServer BOOL: if true, manually use handleUpgrade() instead
# - verifyClient FUNC(OBJ[, FUNC2(BOOL)])
# - handles Origin [C]
# - OBJ:
# - origin STR: Origin [C]
# - secure BOOL
# - req REQ
# - if no FUNC2, FUNC must return BOOL
# - if BOOL false, send 401
# - handleProtocols FUNC(SUBPROTOCOL_ARR, FUNC2(BOOL, SUBPROTOCOL)):
# - handles Sec-Websocket-Protocol [C]
# - FUNC() calls FUNC2() synchronously.
# - If false, send 401
# - if FUNC is undefined, returns first SUBPROTOCOL asked by client
# - does not support any extension (e.g. permessage-deflate)
# - clientTracking BOOL: if true (def), fill WSOCKETSERVER.clients
#Use HTTPS for wss://
#FUNC() not called if OBJ.server
WSOCKETSERVER.on
("headers", FUNC(OBJ)) #HTTP[S] upgrade response headers
WSOCKETSERVER.on
("connection", FUNC(WSOCKET)) #
WSOCKETSERVER.on
("error", FUNC(WSOCKET)) #
WSOCKETSERVER.close
([UINT, ][STR]) #
WSOCKETSERVER.handleUpgrade
(REQ, SOCKET, BUFFER,
FUNC(WSOCKET)) #To pass to a HTTP[S].SERVER "upgrade" event handler, to allow Upgrade: websocket [C]
WSOCKETSERVER.path #
WSOCKETSERVER.clients #WSOCKET_ARR
WSOCKETSERVER._server #Underlying NET.SERVER
/=+===============================+=\
/ : : \
)==: COMMAND LINE :==(
\ :_______________________________: /
\=+===============================+=/
wscat #Command line
-l PORT #Server mode
-c URL #Client mode
--host HOST #
-o ORIGIN #
-s SUBPROTOCOL #
-n BOOL #Inverse of rejectUnauthorized
-H HEADER_VAR:VAL #
--auth USERNAME:PASSWORDa #
-p PROTOCOL_VERSION #