Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/roma-glushko/socket.io-redis-emitter

⚡️ An async Redis-based Socket.IO emitter for Python.
https://github.com/roma-glushko/socket.io-redis-emitter

socket-io socketio socketio-emitter socketio-python socketio-redis

Last synced: 2 months ago
JSON representation

⚡️ An async Redis-based Socket.IO emitter for Python.

Awesome Lists containing this project

README

        

# Socket.IO Redis Emitter

This is an asynchronous Redis-based [Socket.IO emitter](https://socket.io/docs/v4/emitting-events/) for Python.

## Installation

```bash
pip install socket.io-redis-emitter
# or
poetry add socket.io-redis-emitter
```

## Features

- High quality, typed and modern Python codebase
- Clean, concise and Pythonic API
- Uses [redis](https://redis.readthedocs.io/en/latest/) as a Redis client
- Supports namespaces, rooms and regular Socket.IO message emitting

```python
import redis
from socketio_emitter import Emitter

client = redis.Redis(...)
emitter = Emitter(client=client)

async with emitter.namespace("/nsp") as nsp:
async with nsp.rooms("room1", "room2") as clients:
await clients.emit("machineStatus", {"status": "ok"})
```

- Remote requests to join, leave rooms or to disconnect

```python
import redis
from socketio_emitter import Emitter

client = redis.Redis(...)
emitter = Emitter(client=client)

async with emitter.namespace("/nsp") as nsp:
async with nsp.rooms("room1", "room2") as clients:
await clients.join("room3")
# await clients.leave("room3")
# await clients.disconnect()
```