Qore WebSocketUtil Module Reference 1.4.1
Loading...
Searching...
No Matches
WebSocketUtil.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* WebSocketUtil.qm Copyright 2013 - 2022 Qore Technologies, s.r.o.
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23*/
24
25// minimum required Qore version
26
27// require type definitions everywhere
28
29// enable all warnings
30
31// assume local var scope, do not use "$" for vars, members, and method calls
32
33
78namespace WebSocketUtil {
80 public hashdecl WsMsgInfo {
81 int op;
82 bool masked;
83 int close;
84 bool fin;
85 *data msg;
86 };
87
89 const WS_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
90
92 const WS_FIN = (1 << 7);
93
98 const WSOP_Continuation = 0x0;
99
101 const WSOP_Text = 0x1;
102
104 const WSOP_Binary = 0x2;
105
107 const WSOP_Close = 0x8;
108
110 const WSOP_Ping = 0x9;
111
113 const WSOP_Pong = 0xa;
114
116 const WSOPMap = {
117 WSOP_Continuation: "CONTINUATION",
118 WSOP_Text: "TEXT",
119 WSOP_Binary: "BINARY",
120 WSOP_Close: "CLOSE",
121 WSOP_Ping: "PING",
122 WSOP_Pong: "PONG",
123 };
125
130 const WSCC_NormalClosure = 1000;
131
133 const WSCC_GoingAway = 1001;
134
136 const WSCC_ProtocolError = 1002;
137
140
142 const WSCC_NoStatusRcvd = 1005;
143
146
148 const WSCC_InvalidData = 1007;
149
152
154 const WSCC_MessageTooBig = 1009;
155
157 const WSCC_MandatoryExt = 1010;
158
161
163 const WSCC_TlsHandshake = 1015;
164
166 const WSCCMap = {
167 WSCC_NormalClosure: "Normal Closure",
168 WSCC_GoingAway: "Going Away",
169 WSCC_ProtocolError: "Protocol Error",
170 WSCC_UnsupportedData: "Unsupported Data",
171 WSCC_NoStatusRcvd: "No Status Rcvd",
172 WSCC_AbnormalClosure: "Abnormal Closure",
173 WSCC_InvalidData: "Invalid Frame Payload Data",
174 WSCC_PolicyViolation: "Policy Violation",
175 WSCC_MessageTooBig: "Message Too Big",
176 WSCC_MandatoryExt: "Mandatory Ext.",
177 WSCC_InternalServerError: "Internal Server Error",
178 WSCC_TlsHandshake: "TLS Handshake",
179 };
181
183 binary ws_encode_message(data msg, int op = -1, *bool masked, bool fin = True);
184
185
187
201 hash<WsMsgInfo> ws_read_message(Socket sock, *timeout to);
202
203
205
211 string ws_get_response_key(string key);
212
213};
const WSCC_ProtocolError
"Protocol Error" code
Definition: WebSocketUtil.qm.dox.h:136
const WSCC_NormalClosure
Definition: WebSocketUtil.qm.dox.h:130
const WSCC_GoingAway
"Going Away" code
Definition: WebSocketUtil.qm.dox.h:133
const WSCCMap
maps from close codes to text descriptions
Definition: WebSocketUtil.qm.dox.h:166
const WSCC_AbnormalClosure
"Abnormal Closure" code
Definition: WebSocketUtil.qm.dox.h:145
const WSCC_UnsupportedData
"Unsupported Data" code
Definition: WebSocketUtil.qm.dox.h:139
const WSCC_NoStatusRcvd
"No Status Rcvd" code
Definition: WebSocketUtil.qm.dox.h:142
const WSCC_InvalidData
"Invalid Frame Payload Data" code
Definition: WebSocketUtil.qm.dox.h:148
const WSCC_MessageTooBig
"Message Too Big" code
Definition: WebSocketUtil.qm.dox.h:154
const WSCC_TlsHandshake
"TLS Handshake" code
Definition: WebSocketUtil.qm.dox.h:163
const WSCC_InternalServerError
"Internal Server Error" code
Definition: WebSocketUtil.qm.dox.h:160
const WSCC_MandatoryExt
"Mandatory Ext." code
Definition: WebSocketUtil.qm.dox.h:157
const WSCC_PolicyViolation
"Policy Violation" code
Definition: WebSocketUtil.qm.dox.h:151
const WSOP_Text
text frame opcode
Definition: WebSocketUtil.qm.dox.h:101
const WSOP_Binary
binary frame opcode
Definition: WebSocketUtil.qm.dox.h:104
const WSOP_Close
connection code opcode
Definition: WebSocketUtil.qm.dox.h:107
const WSOPMap
maps from opcodes to text descriptions
Definition: WebSocketUtil.qm.dox.h:116
const WSOP_Pong
pong opcode
Definition: WebSocketUtil.qm.dox.h:113
const WSOP_Ping
ping opcode
Definition: WebSocketUtil.qm.dox.h:110
const WSOP_Continuation
Definition: WebSocketUtil.qm.dox.h:98
the WebSocketUtil namespace contains all the definitions in the WebSocketUtil module
Definition: WebSocketUtil.qm.dox.h:78
string ws_get_response_key(string key)
returns a string response key from the binary key and the WebSocket GUID value
const WS_FIN
the final fragment in a message
Definition: WebSocketUtil.qm.dox.h:92
binary ws_encode_message(data msg, int op=-1, *bool masked, bool fin=True)
encodes a message for sending over a websocket socket
hash< WsMsgInfo > ws_read_message(Socket sock, *timeout to)
read and decode a message from a socket
const WS_GUID
WebSocket GUID.
Definition: WebSocketUtil.qm.dox.h:89
WebSocket message info.
Definition: WebSocketUtil.qm.dox.h:80