Websocket Client Library
Project description
# Dataplicity Lomond
Tranquil WebSockets for Python. [Docs](https://lomond.readthedocs.io/)
Lomond is a Websocket client which turns a websocket connection in to
an orderly stream of _events_. No threads or callbacks necessary.
## How to Use
First construct a `WebSocket` object, then iterate over it to generate
an orderly sequence of events.
## Example
The following is a silly example that connects to a websocket server
(in this case a public echo server), and sends a string of text
every 5 seconds.
```python
from lomond import WebSocket
websocket = WebSocket('wss://echo.websocket.org')
for event in websocket:
if event.name == 'poll':
websocket.send_text('Hello, World')
elif event.name == 'text':
print(event.text)
```
## Events
A successful websocket connection will result in a series of events
such as the following:
```
┌──────────────────────┐
│ Connecting │ Contacting server
└──────────────────────┘
│
▼
┌──────────────────────┐ Connected to server (but
│ Connected │ not yet sent data)
└──────────────────────┘
│
▼
┌──────────────────────┐ Negotiated Websocket
│ Ready │ handshake
└──────────────────────┘
│ ┌───────────┐
│ │ │
▼ ▼ │
┌──────────────────────┐ │ Send and receive
│ Binary / Text / Poll │──┘ application data
└──────────────────────┘
│
▼
┌──────────────────────┐ Websocket close
│ Closed │ handshake
└──────────────────────┘
│
▼
┌──────────────────────┐
│ Disconnected │ Disconnected TCP/IP
└──────────────────────┘ connection to server
```
Tranquil WebSockets for Python. [Docs](https://lomond.readthedocs.io/)
Lomond is a Websocket client which turns a websocket connection in to
an orderly stream of _events_. No threads or callbacks necessary.
## How to Use
First construct a `WebSocket` object, then iterate over it to generate
an orderly sequence of events.
## Example
The following is a silly example that connects to a websocket server
(in this case a public echo server), and sends a string of text
every 5 seconds.
```python
from lomond import WebSocket
websocket = WebSocket('wss://echo.websocket.org')
for event in websocket:
if event.name == 'poll':
websocket.send_text('Hello, World')
elif event.name == 'text':
print(event.text)
```
## Events
A successful websocket connection will result in a series of events
such as the following:
```
┌──────────────────────┐
│ Connecting │ Contacting server
└──────────────────────┘
│
▼
┌──────────────────────┐ Connected to server (but
│ Connected │ not yet sent data)
└──────────────────────┘
│
▼
┌──────────────────────┐ Negotiated Websocket
│ Ready │ handshake
└──────────────────────┘
│ ┌───────────┐
│ │ │
▼ ▼ │
┌──────────────────────┐ │ Send and receive
│ Binary / Text / Poll │──┘ application data
└──────────────────────┘
│
▼
┌──────────────────────┐ Websocket close
│ Closed │ handshake
└──────────────────────┘
│
▼
┌──────────────────────┐
│ Disconnected │ Disconnected TCP/IP
└──────────────────────┘ connection to server
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lomond-0.1.14.tar.gz
(22.5 kB
view hashes)
Built Distribution
Close
Hashes for lomond-0.1.14-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dc92614a8c90a87a8a9f20e173bb10c7eb2937b7ecdf43750cfa7359f5ada70 |
|
MD5 | 4ef011768f626fdf3cdcaf517b147103 |
|
BLAKE2b-256 | fa37c229eaf8b6cd82085d0fec6a764ae40d78ac95a4d4df85b954845ed35530 |