diff --git a/libraries/script-engine/src/WebSocketClass.cpp b/libraries/script-engine/src/WebSocketClass.cpp
index 56753f07d1..73774912a9 100644
--- a/libraries/script-engine/src/WebSocketClass.cpp
+++ b/libraries/script-engine/src/WebSocketClass.cpp
@@ -68,6 +68,18 @@ void WebSocketClass::close(QWebSocketProtocol::CloseCode closeCode, QString reas
_webSocket->close(closeCode, reason);
}
+/**jsdoc
+ * Called when the connection closes.
+ * @callback WebSocket~onCloseCallback
+ * @param {WebSocket.CloseData} data - Information on the connection closure.
+ */
+/**jsdoc
+ * Information on a connection being closed.
+ * @typedef {object} WebSocket.CloseData
+ * @property {WebSocket.CloseCode} code - The reason why the connection was closed.
+ * @property {string} reason - Description of the reason why the connection was closed.
+ * @property {boolean} wasClean - true
if the connection closed cleanly, false
if it didn't.
+ */
void WebSocketClass::handleOnClose() {
bool hasError = (_webSocket->error() != QAbstractSocket::UnknownSocketError);
if (_onCloseEvent.isFunction()) {
@@ -81,12 +93,73 @@ void WebSocketClass::handleOnClose() {
}
}
+/**jsdoc
+ * Called when an error occurs.
+ * @callback WebSocket~onErrorCallback
+ * @param {WebSocket.SocketError} error - The error.
+ */
+/**jsdoc
+ * Information on a socket error.
+ *
Value | Name | Description |
---|---|---|
0 | ConnectionRefusedError | The connection was refused or timed out. |
1 | RemoteHostClosedError | The remote host closed the connection. |
2 | HostNotFoundError | The host address was not found. |
3 | SocketAccessError | The socket operation failed because the application doesn't have + * the necessary privileges. |
4 | SocketResourceError | The local system ran out of resources (e.g., too many + * sockets). |
5 | SocketTimeoutError | The socket operation timed out. |
6 | DatagramTooLargeError | The datagram was larger than the OS's limit. |
7 | NetworkError | An error occurred with the network. |
8 | AddressInUseError | The is already in use and cannot be reused. |
9 | SocketAddressNotAvailableError | The address specified does not belong to the + * host. |
10 | UnsupportedSocketOperationError | The requested socket operation is not supported + * by the local OS. |
11 | ProxyAuthenticationRequiredError | The socket is using a proxy and requires + * authentication. |
12 | SslHandshakeFailedError | The SSL/TLS handshake failed. |
13 | UnfinishedSocketOperationError | The last operation has not finished yet. |
14 | ProxyConnectionRefusedError | Could not contact the proxy server because connection + * was denied. |
15 | ProxyConnectionClosedError | The connection to the proxy server was unexpectedly + * closed. |
16 | ProxyConnectionTimeoutError | The connection to the proxy server timed + * out. |
17 | ProxyNotFoundError | The proxy address was not found. |
18 | ProxyProtocolError | Connection to the proxy server failed because the server + * response could not be understood. |
19 | OperationError | An operation failed because the socket state did not permit + * it. |
20 | SslInternalError | Internal error in the SSL library being used. |
21 | SslInvalidUserDataError | Error in the SSL library because of invalid + * data. |
22 | TemporaryError | A temporary error occurred. |
-1 | UnknownSocketError | An unknown error occurred. |
Constructed by new WebSocket(...)
in Interface, client entity, avatar, and server entity scripts, or the
+ * {@link WebSocketServer} class in server entity and assignment client scripts.
+ *
+ *
Note: Does not support secure, wss:
protocol.
Value | Name | Description |
---|---|---|
0 | CONNECTING | The connection is opening. |
1 | OPEN | The connection is open. |
2 | CLOSING | The connection is closing. |
3 | CLOSED | The connection is closed. |
Value | Name | Description |
---|---|---|
1000 | Normal | Normal closure. |
1001 | GoingAway | Going away. |
1002 | ProtocolError | Protocol error. |
1003 | DatatypeNotSupported | Unsupported data. |
1004 | Reserved1004 | Reserved. |
1005 | MissingStatusCode | No status received. |
1006 | AbnormalDisconnection | abnormal closure. |
1007 | WrongDatatype | Invalid frame payload data. |
1008 | PolicyViolated | Policy violation. |
1009 | TooMuchData | Message too big. |
1010 | MissingExtension | Mandatory extension missing. |
1011 | BadOperation | Internal server error. |
1015 | TlsHandshakeFailed | TLS handshake failed. |