History

WebSocket and WebSocketServer JSDoc

David Rowe committed 6 years ago

Commit 13abf7f1 parent 3a2d9b33 files · +209 −0Browse files

Showing the changes to libraries/script-engine/src/WebSocketClass.cpp (1 of 3 files). Show all

Unified · Split

libraries/script-engine/src/WebSocketClass.cpp+30−0
@@ -68,6 +68,18 @@ void WebSocketClass::close(QWebSocketProtocol::CloseCode closeCode, QString reas · 67 unmodified lines
6868 _webSocket->close(closeCode, reason);
6969 }
7070
71+/**jsdoc
72+ * Called when the connection closes.
73+ * @callback WebSocket~onCloseCallback
74+ * @param {WebSocket.CloseData} data - Information on the connection closure.
75+ */
76+/**jsdoc
77+ * Information on a connection being closed.
78+ * @typedef {object} WebSocket.CloseData
79+ * @property {WebSocket.CloseCode} code - The reason why the connection was closed.
80+ * @property {string} reason - Description of the reason why the connection was closed.
81+ * @property {boolean} wasClean - <code>true</code> if the connection closed cleanly, <code>false</code> if it didn't.
82+ */
7183 void WebSocketClass::handleOnClose() {
7284 bool hasError = (_webSocket->error() != QAbstractSocket::UnknownSocketError);
7385 if (_onCloseEvent.isFunction()) {
@@ -81,12 +93,26 @@ void WebSocketClass::handleOnClose() { · 7 unmodified lines
8193 }
8294 }
8395
96+/**jsdoc
97+ * Called when an error occurs.
98+ * @callback WebSocket~onErrorCallback
99+ */
84100 void WebSocketClass::handleOnError(QAbstractSocket::SocketError error) {
85101 if (_onErrorEvent.isFunction()) {
86102 _onErrorEvent.call();
87103 }
88104 }
89105
106+/**jsdoc
107+ * Triggered when a message is received.
108+ * @callback WebSocket~onMessageCallback
109+ * @param {WebSocket.MessageData} message - The message received.
110+ */
111+/**jsdoc
112+ * A message received on a WebSocket connection.
113+ * @typedef {object} WebSocket.MessageData
114+ * @property {string} data - The message content.
115+ */
90116 void WebSocketClass::handleOnMessage(const QString& message) {
91117 if (_onMessageEvent.isFunction()) {
92118 QScriptValueList args;
@@ -97,6 +123,10 @@ void WebSocketClass::handleOnMessage(const QString& message) { · 4 unmodified lines
97123 }
98124 }
99125
126+/**jsdoc
127+ * Called when the connection opens.
128+ * @callback WebSocket~onOpenCallback
129+ */
100130 void WebSocketClass::handleOnOpen() {
101131 if (_onOpenEvent.isFunction()) {
102132 _onOpenEvent.call();