Skip to content

Commit 19ad4af

Browse files
authored
Update the readme to include the client-side ping event. (#74)
1 parent a6c132a commit 19ad4af

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ Features
7777
successfully or unsuccessfully executed commands, with built-in Prometheus
7878
and logging backends.
7979

80+
- Connection maintenance
81+
82+
SocketShark supports keeping the WebSocket connection alive and automatic
83+
discovery of its closure through automated server-side pings and handlers
84+
for client-side pings.
85+
8086
.. _websockets: https://websockets.readthedocs.io/
8187

8288
Quick start
@@ -105,6 +111,7 @@ supports the following events:
105111
- ``subscribe``: Subscribe to a topic
106112
- ``message``: Send a message to a topic
107113
- ``unsubscribe``: Unsubscribe from a topic
114+
- ``ping``: Monitor connectivity
108115

109116
Responses usually contain a ``status`` field which can be ``ok`` or ``error``.
110117
In case of an error, an ``error`` field is supplied containing the error
@@ -296,6 +303,28 @@ Example server responses (successful and unsuccessful):
296303
"error": "Subscription does not exist."
297304
}
298305
306+
Ping
307+
~~~~
308+
309+
Clients can send a ``ping`` message and Socketshark will send a ``pong`` back
310+
immediately, without contacting any services. Clients may choose to send pings
311+
and monitor for pongs to e.g. detect failed WebSocket connections, display
312+
latency metrics, etc. Furthermore, the ping message may contain some ``data``,
313+
which the pong message should repeat back.
314+
315+
Example client request:
316+
317+
.. code:: json
318+
319+
{"event": "ping", "data": "foobar"}
320+
321+
Example server response:
322+
323+
.. code:: json
324+
325+
{"event": "pong", "data": "foobar"}
326+
327+
299328
Service Protocol
300329
================
301330

0 commit comments

Comments
 (0)