Skip to content

Commit

Permalink
Update the readme to include the client-side ping event. (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
wojcikstefan authored Aug 25, 2021
1 parent a6c132a commit 19ad4af
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ Features
successfully or unsuccessfully executed commands, with built-in Prometheus
and logging backends.

- Connection maintenance

SocketShark supports keeping the WebSocket connection alive and automatic
discovery of its closure through automated server-side pings and handlers
for client-side pings.

.. _websockets: https://websockets.readthedocs.io/

Quick start
Expand Down Expand Up @@ -105,6 +111,7 @@ supports the following events:
- ``subscribe``: Subscribe to a topic
- ``message``: Send a message to a topic
- ``unsubscribe``: Unsubscribe from a topic
- ``ping``: Monitor connectivity

Responses usually contain a ``status`` field which can be ``ok`` or ``error``.
In case of an error, an ``error`` field is supplied containing the error
Expand Down Expand Up @@ -296,6 +303,28 @@ Example server responses (successful and unsuccessful):
"error": "Subscription does not exist."
}
Ping
~~~~

Clients can send a ``ping`` message and Socketshark will send a ``pong`` back
immediately, without contacting any services. Clients may choose to send pings
and monitor for pongs to e.g. detect failed WebSocket connections, display
latency metrics, etc. Furthermore, the ping message may contain some ``data``,
which the pong message should repeat back.

Example client request:

.. code:: json
{"event": "ping", "data": "foobar"}
Example server response:

.. code:: json
{"event": "pong", "data": "foobar"}
Service Protocol
================

Expand Down

0 comments on commit 19ad4af

Please sign in to comment.