socket.io-redis-emitter

An asynchronous Redis-based Socket.IO emitter for Python


Keywords
socket, io, redis, websocket, emitter, library, socket-io, socketio, socketio-emitter, socketio-python, socketio-redis
License
MIT
Install
pip install socket.io-redis-emitter==0.0.3

Documentation

Socket.IO Redis Emitter

This is an asynchronous Redis-based Socket.IO emitter for Python.

Installation

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 as a Redis client
  • Supports namespaces, rooms and regular Socket.IO message emitting
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
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()