A simple framework for websocket event-based messaging using flask websockets under the hood
Project description
Bounce-WS
Overview
This project is a WebSocket-based framework built with FastAPI and Uvicorn, designed to facilitate real-time communication between the frontend and backend.
Features
- Real-time WebSocket communication.
- Multi-threaded server for efficient handling of connections.
- Scalable and modular design for easy integration.
- Prebuilt logic for messages
Installation
To install the project, clone the repository and install the required dependencies:
git clone https://github.com/Allorak/bounce-ws
cd websocket-api
pip install -r requirements.txt
Alternatively you can use pip to install:
pip install https://github.com/Allorak/bounce-ws
Or install from PyPI index:
pip install bounce-ws
Core ideas
The main idea is that client and server use websockets for message exchange with specified message structure:
{
"event": "<event name>",
"data": "<message payload>",
"timestamp": "<iso formated send time timestamp without offset>"
}
For interacting with the server clients firstly have to subscribe to the needed events sending following message:
{
"event": "subscribe",
"data": {
"events": [<list of event names to subscribe to>]
},
"timestamp": "<iso formated send time timestamp without offset>"
}
You may specify "*" in "events" key to subscribe to all events, provided by the server
In a similar way client may unsubscribe from the specified events:
{
"event": "unsubscribe",
"data": {
"events": [<list of event names to unsubscribe from>]
},
"timestamp": "<iso formated send time timestamp without offset>"
}
Framework provides following options for message exchange:
- Clients can subscribe to the needed events and unsubscribe from them
- Send message using AbstractSender calling "send" method manually
- Send message using TimedAbstractSender calling "send" method repeatedly
- Handle incoming messages with AbstractHandler, discarding messages of the same event with timestamp larger than last handled
Example
Usage examples can be found in examples/ folder
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
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 bounce_ws-0.9.9.tar.gz.
File metadata
- Download URL: bounce_ws-0.9.9.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c28fb7cfeb6e938360eb1d6e981356a4dc4788a54113192383dbdcc13e7d8664
|
|
| MD5 |
487ae43f5935d3a74954bc111b16b966
|
|
| BLAKE2b-256 |
52ade45d4f4aded342b1f681f66f71e988f30cd238895f1c50483634112cd123
|
File details
Details for the file bounce_ws-0.9.9-py3-none-any.whl.
File metadata
- Download URL: bounce_ws-0.9.9-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e9af959f7f1782116ca2aa1c07594dddc66bc235bd1225ca6f75ab4762c730d
|
|
| MD5 |
1b0b9f550ed830bd5ece1b907c6a5a97
|
|
| BLAKE2b-256 |
f1778d7da12cf2f61f8f11faf6987f630f9b4ed3d541247eb3b981cad45df072
|