# Conflicts: # CMakeLists.txt # README.md # cmake/externals/glad32es/CMakeLists.txt # cmake/externals/glad41/CMakeLists.txt # cmake/externals/glad45/CMakeLists.txt # cmake/externals/polyvox/CMakeLists.txt # cmake/externals/quazip/CMakeLists.txt # cmake/externals/vhacd/CMakeLists.txt # cmake/init.cmake # cmake/ports/hifi-deps/CONTROL # cmake/ports/sdl2/CONTROL # cmake/ports/sdl2/disable-hidapi-for-uwp.patch # cmake/ports/sdl2/enable-winrt-cmake.patch # cmake/ports/sdl2/fix-arm64-headers.patch # cmake/ports/sdl2/fix-x86-windows.patch # cmake/ports/sdl2/portfile.cmake # cmake/ports/sdl2/vcpkg-cmake-wrapper.cmake # cmake/ports/tbb/portfile.cmake # hifi_vcpkg.py # interface/src/avatar/MyAvatar.h # libraries/avatars-renderer/src/avatars-renderer/Avatar.h # libraries/avatars/src/AvatarData.h # libraries/entities-renderer/src/RenderableEntityItem.h # libraries/entities/src/EntityItem.cpp # libraries/entities/src/EntityItem.h # libraries/fbx/src/GLTFSerializer.cpp # libraries/graphics-scripting/src/graphics-scripting/Forward.h # libraries/networking/src/AddressManager.cpp # libraries/networking/src/DomainHandler.h # libraries/procedural/src/procedural/ProceduralMaterialCache.cpp # libraries/render-utils/src/HighlightEffect.cpp # libraries/render-utils/src/MeshPartPayload.cpp # libraries/render-utils/src/Model.cpp # libraries/render-utils/src/RenderShadowTask.cpp # libraries/script-engine/src/WebSocketClass.cpp
Showing the changes to libraries/script-engine/src/WebSocketClass.cpp (1 of 403 files). Show all
Unified · Split
| @@ -76,6 +76,18 @@ void WebSocketClass::close(QWebSocketProtocol::CloseCode closeCode, QString reas · 75 unmodified lines | |||
| 76 | _webSocket->close(closeCode, reason); | 76 | _webSocket->close(closeCode, reason); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | /**jsdoc | ||
| 80 | * Called when the connection closes. | ||
| 81 | * @callback WebSocket~onCloseCallback | ||
| 82 | * @param {WebSocket.CloseData} data - Information on the connection closure. | ||
| 83 | */ | ||
| 84 | /**jsdoc | ||
| 85 | * Information on a connection being closed. | ||
| 86 | * @typedef {object} WebSocket.CloseData | ||
| 87 | * @property {WebSocket.CloseCode} code - The reason why the connection was closed. | ||
| 88 | * @property {string} reason - Description of the reason why the connection was closed. | ||
| 89 | * @property {boolean} wasClean - <code>true</code> if the connection closed cleanly, <code>false</code> if it didn't. | ||
| 90 | */ | ||
| 79 | void WebSocketClass::handleOnClose() { | 91 | void WebSocketClass::handleOnClose() { |
| 80 | bool hasError = (_webSocket->error() != QAbstractSocket::UnknownSocketError); | 92 | bool hasError = (_webSocket->error() != QAbstractSocket::UnknownSocketError); |
| 81 | if (_onCloseEvent.isFunction()) { | 93 | if (_onCloseEvent.isFunction()) { |
| @@ -89,12 +101,73 @@ void WebSocketClass::handleOnClose() { · 7 unmodified lines | |||
| 89 | } | 101 | } |
| 90 | } | 102 | } |
| 91 | 103 | ||
| 104 | /**jsdoc | ||
| 105 | * Called when an error occurs. | ||
| 106 | * @callback WebSocket~onErrorCallback | ||
| 107 | * @param {WebSocket.SocketError} error - The error. | ||
| 108 | */ | ||
| 109 | /**jsdoc | ||
| 110 | * <p>The type of socket error.</p> | ||
| 111 | * <table> | ||
| 112 | * <thead> | ||
| 113 | * <tr><th>Value</th><th>Name</th><th>Description</th></tr> | ||
| 114 | * </thead> | ||
| 115 | * <tbody> | ||
| 116 | * <tr><td><code>0</code></td><td>ConnectionRefusedError</td><td>The connection was refused or timed out.</td></tr> | ||
| 117 | * <tr><td><code>1</code></td><td>RemoteHostClosedError</td><td>The remote host closed the connection.</td></tr> | ||
| 118 | * <tr><td><code>2</code></td><td>HostNotFoundError</td><td>The host address was not found.</td></tr> | ||
| 119 | * <tr><td><code>3</code></td><td>SocketAccessError</td><td>The socket operation failed because the application doesn't have | ||
| 120 | * the necessary privileges.</td></tr> | ||
| 121 | * <tr><td><code>4</code></td><td>SocketResourceError</td><td>The local system ran out of resources (e.g., too many | ||
| 122 | * sockets).</td></tr> | ||
| 123 | * <tr><td><code>5</code></td><td>SocketTimeoutError</td><td>The socket operation timed out.</td></tr> | ||
| 124 | * <tr><td><code>6</code></td><td>DatagramTooLargeError</td><td>The datagram was larger than the OS's limit.</td></tr> | ||
| 125 | * <tr><td><code>7</code></td><td>NetworkError</td><td>An error occurred with the network.</td></tr> | ||
| 126 | * <tr><td><code>8</code></td><td>AddressInUseError</td><td>The is already in use and cannot be reused.</td></tr> | ||
| 127 | * <tr><td><code>9</code></td><td>SocketAddressNotAvailableError</td><td>The address specified does not belong to the | ||
| 128 | * host.</td></tr> | ||
| 129 | * <tr><td><code>10</code></td><td>UnsupportedSocketOperationError</td><td>The requested socket operation is not supported | ||
| 130 | * by the local OS.</td></tr> | ||
| 131 | * <tr><td><code>11</code></td><td>ProxyAuthenticationRequiredError</td><td>The socket is using a proxy and requires | ||
| 132 | * authentication.</td></tr> | ||
| 133 | * <tr><td><code>12</code></td><td>SslHandshakeFailedError</td><td>The SSL/TLS handshake failed.</td></tr> | ||
| 134 | * <tr><td><code>13</code></td><td>UnfinishedSocketOperationError</td><td>The last operation has not finished yet.</td></tr> | ||
| 135 | * <tr><td><code>14</code></td><td>ProxyConnectionRefusedError</td><td>Could not contact the proxy server because connection | ||
| 136 | * was denied.</td></tr> | ||
| 137 | * <tr><td><code>15</code></td><td>ProxyConnectionClosedError</td><td>The connection to the proxy server was unexpectedly | ||
| 138 | * closed.</td></tr> | ||
| 139 | * <tr><td><code>16</code></td><td>ProxyConnectionTimeoutError</td><td>The connection to the proxy server timed | ||
| 140 | * out.</td></tr> | ||
| 141 | * <tr><td><code>17</code></td><td>ProxyNotFoundError</td><td>The proxy address was not found.</td></tr> | ||
| 142 | * <tr><td><code>18</code></td><td>ProxyProtocolError</td><td>Connection to the proxy server failed because the server | ||
| 143 | * response could not be understood.</td></tr> | ||
| 144 | * <tr><td><code>19</code></td><td>OperationError</td><td>An operation failed because the socket state did not permit | ||
| 145 | * it.</td></tr> | ||
| 146 | * <tr><td><code>20</code></td><td>SslInternalError</td><td>Internal error in the SSL library being used.</td></tr> | ||
| 147 | * <tr><td><code>21</code></td><td>SslInvalidUserDataError</td><td>Error in the SSL library because of invalid | ||
| 148 | * data.</td></tr> | ||
| 149 | * <tr><td><code>22</code></td><td>TemporaryError</td><td>A temporary error occurred.</td></tr> | ||
| 150 | * <tr><td><code>-1</code></td><td>UnknownSocketError</td><td>An unknown error occurred.</td></tr> | ||
| 151 | * </tbody> | ||
| 152 | * </table> | ||
| 153 | * @typedef {number} WebSocket.SocketError | ||
| 154 | */ | ||
| 92 | void WebSocketClass::handleOnError(QAbstractSocket::SocketError error) { | 155 | void WebSocketClass::handleOnError(QAbstractSocket::SocketError error) { |
| 93 | if (_onErrorEvent.isFunction()) { | 156 | if (_onErrorEvent.isFunction()) { |
| 94 | _onErrorEvent.call(); | 157 | _onErrorEvent.call(); |
| 95 | } | 158 | } |
| 96 | } | 159 | } |
| 97 | 160 | ||
| 161 | /**jsdoc | ||
| 162 | * Triggered when a message is received. | ||
| 163 | * @callback WebSocket~onMessageCallback | ||
| 164 | * @param {WebSocket.MessageData} message - The message received. | ||
| 165 | */ | ||
| 166 | /**jsdoc | ||
| 167 | * A message received on a WebSocket connection. | ||
| 168 | * @typedef {object} WebSocket.MessageData | ||
| 169 | * @property {string} data - The message content. | ||
| 170 | */ | ||
| 98 | void WebSocketClass::handleOnMessage(const QString& message) { | 171 | void WebSocketClass::handleOnMessage(const QString& message) { |
| 99 | if (_onMessageEvent.isFunction()) { | 172 | if (_onMessageEvent.isFunction()) { |
| 100 | QScriptValueList args; | 173 | QScriptValueList args; |
| @@ -124,6 +197,10 @@ void WebSocketClass::handleOnBinaryMessage(const QByteArray& message) { · 23 unmodified lines | |||
| 124 | } | 197 | } |
| 125 | } | 198 | } |
| 126 | 199 | ||
| 200 | /**jsdoc | ||
| 201 | * Called when the connection opens. | ||
| 202 | * @callback WebSocket~onOpenCallback | ||
| 203 | */ | ||
| 127 | void WebSocketClass::handleOnOpen() { | 204 | void WebSocketClass::handleOnOpen() { |
| 128 | if (_onOpenEvent.isFunction()) { | 205 | if (_onOpenEvent.isFunction()) { |
| 129 | _onOpenEvent.call(); | 206 | _onOpenEvent.call(); |