Skip to content

Commit 92a87c0

Browse files
committed
example python API documentation on websocket
1 parent 5ebad8c commit 92a87c0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

python/websocketprovider.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ def to_bytes(field):
4646

4747

4848
class WebsocketClient(object):
49+
"""
50+
This class implements a websocket client. See :py:func:`~WebsocketClient.connect` for more details.
51+
"""
4952
_registered_clients = []
5053

5154
def __init__(self, provider, handle=None):
@@ -157,6 +160,12 @@ def connect(self, url, headers=None, on_connected=nop, on_disconnected=nop, on_e
157160
:param function(bytes) -> bool on_data: function to call when data is read from the websocket
158161
:return: if the connection has started, but not necessarily if it succeeded
159162
:rtype: bool
163+
164+
:Example:
165+
>>> provider = list(WebsocketProvider)[0]
166+
>>> client = provider.create_instance()
167+
>>> client.connect("ws://localhost:8080", {})
168+
True
160169
"""
161170
if self._connected:
162171
raise RuntimeError("Cannot use connect() twice on the same WebsocketClient")

0 commit comments

Comments
 (0)