Websocket Client Library
Project description
# Dataplicity Lomond
[](https://pypi.org/project/lomond/)
[](https://pypi.org/project/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
To connect to a WebSocket URL construct a `WebSocket` object, then iterate over it to generate an orderly sequence of events.
You will receive a ``Binary`` or ``Text`` event when the server sends you a message,
you may send a message with the ``send_binary`` or ``send_text`` methods.
## 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
```
[](https://pypi.org/project/lomond/)
[](https://pypi.org/project/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
To connect to a WebSocket URL construct a `WebSocket` object, then iterate over it to generate an orderly sequence of events.
You will receive a ``Binary`` or ``Text`` event when the server sends you a message,
you may send a message with the ``send_binary`` or ``send_text`` methods.
## 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.16a1.tar.gz
(25.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lomond-0.1.16a1.tar.gz.
File metadata
- Download URL: lomond-0.1.16a1.tar.gz
- Upload date:
- Size: 25.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d52684f8361b8dc8841f2565f677d1db555d7d1fa2f87abc4dd5a4d8cbe8fcf
|
|
| MD5 |
e5177c4c229fe44fff053f45512f4d84
|
|
| BLAKE2b-256 |
47e115010c1fabd3af114cbfb443cb7864595c47f3701787b096ec522fb4740c
|
File details
Details for the file lomond-0.1.16a1-py2.py3-none-any.whl.
File metadata
- Download URL: lomond-0.1.16a1-py2.py3-none-any.whl
- Upload date:
- Size: 34.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c43f4c59be8d475faeb6dd3b11c5cb54669109b116d73ea3fa930323247edb11
|
|
| MD5 |
66ca9f341d968f5dca3ba90ddf8c8366
|
|
| BLAKE2b-256 |
0278831544729991730ee827edba3f55f24191835b966e25a36c6f328b71c1ef
|