From 13abf7f0167a3816bf5f571dee06d8bbd93c3723 Mon Sep 17 00:00:00 2001
From: David Rowe 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,26 @@ void WebSocketClass::handleOnClose() {
}
}
+/**jsdoc
+ * Called when an error occurs.
+ * @callback WebSocket~onErrorCallback
+ */
void WebSocketClass::handleOnError(QAbstractSocket::SocketError error) {
if (_onErrorEvent.isFunction()) {
_onErrorEvent.call();
}
}
+/**jsdoc
+ * Triggered when a message is received.
+ * @callback WebSocket~onMessageCallback
+ * @param {WebSocket.MessageData} message - The message received.
+ */
+/**jsdoc
+ * A message received on a WebSocket connection.
+ * @typedef {object} WebSocket.MessageData
+ * @property {string} data - The message content.
+ */
void WebSocketClass::handleOnMessage(const QString& message) {
if (_onMessageEvent.isFunction()) {
QScriptValueList args;
@@ -97,6 +123,10 @@ void WebSocketClass::handleOnMessage(const QString& message) {
}
}
+/**jsdoc
+ * Called when the connection opens.
+ * @callback WebSocket~onOpenCallback
+ */
void WebSocketClass::handleOnOpen() {
if (_onOpenEvent.isFunction()) {
_onOpenEvent.call();
diff --git a/libraries/script-engine/src/WebSocketClass.h b/libraries/script-engine/src/WebSocketClass.h
index dbc9729c61..56fb334152 100644
--- a/libraries/script-engine/src/WebSocketClass.h
+++ b/libraries/script-engine/src/WebSocketClass.h
@@ -16,6 +16,68 @@
#include
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. |
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. |
9
10
11
12
15
16
17
18