From 92a87c0a3f981f8e0bd80789b9c19447227445dc Mon Sep 17 00:00:00 2001 From: Jordan Wiens Date: Thu, 25 Apr 2024 19:49:17 -0400 Subject: example python API documentation on websocket --- python/websocketprovider.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'python/websocketprovider.py') diff --git a/python/websocketprovider.py b/python/websocketprovider.py index 70239ccf..420f43c6 100644 --- a/python/websocketprovider.py +++ b/python/websocketprovider.py @@ -46,6 +46,9 @@ def to_bytes(field): class WebsocketClient(object): + """ + This class implements a websocket client. See :py:func:`~WebsocketClient.connect` for more details. + """ _registered_clients = [] def __init__(self, provider, handle=None): @@ -157,6 +160,12 @@ class WebsocketClient(object): :param function(bytes) -> bool on_data: function to call when data is read from the websocket :return: if the connection has started, but not necessarily if it succeeded :rtype: bool + + :Example: + >>> provider = list(WebsocketProvider)[0] + >>> client = provider.create_instance() + >>> client.connect("ws://localhost:8080", {}) + True """ if self._connected: raise RuntimeError("Cannot use connect() twice on the same WebsocketClient") -- cgit v1.3.1