Enhance jsclient-socket documentation

This commit is contained in:
orel committed 2021-02-05 16:58:55 +01:00
1 parent 4bc2435412
commit 13aa5a4e25
1 file changed
+24 -1
+24 -1
View File
@@ -64,12 +64,24 @@
Sends a message of type ``type`` with the provided ``payload`` to the server.
Note that at the time of writing, OctoPrint only supports the ``throttle`` message. See
Note that at the time of writing, OctoPrint only supports the ``throttle`` and ``auth`` messages. See
also the :ref:`Push API documentation <sec-api-push>`.
:param string type: Type of message to send
:param object payload: Payload to send
.. js:function:: OctoPrintClient.socket.sendAuth(userId, session)
Sends an ``auth`` message with the provided ``userId`` and ``session`` to the server.
``session`` is expected to be the ``session`` value retrieved
from any valid :ref:`OctoPrint.browser.login(userId,...) <sec-jsclientlib-browser>` response.
See also the :ref:`Push API documentation <sec-api-push>`.
:param string userId: An existing OctoPrint username
:param string session: A valid session id for the provided username
.. js:function:: OctoPrintClient.socket.onRateTooLow(measured, minimum)
Called by the socket client when the measured message round trip times have been lower than
@@ -102,6 +114,17 @@
Instructs the server to decrease the message rate by 500ms.
Sample to setup an authed socket
================================
.. code-block:: javascript
OctoPrint.socket.connect();
OctoPrint.browser.login("myusername", "mypassword", true)
.done(function(response) {
client.socket.sendAuth("myusername", response.session);
});
.. _sec-jsclient-socket-throttling:
Communication Throttling