Skip to content

0.5.0

Choose a tag to compare

@yezz123 yezz123 released this 16 Jun 12:15
· 1343 commits to main since this release
10bae89

0.5.0

Supporting SocketIO that's allows bi-directional communication between client and server. Bi-directional communications are enabled when a client has Socket.IO in the browser, and a server has also integrated the Socket.IO package. While data can be sent in a number of forms, JSON is the simplest.

Usage

To add SocketIO support to FastAPI all you need to do is import AuthXSocket and pass it FastAPI object.

from fastapi import FastAPI
from authx import AuthXSocket

app = FastAPI()
socket = AuthXSocket(app=app)

you can import AuthXSocket object that exposes most of the SocketIO functionality.

@AuthXSocket.on('leave')
async def handle_leave(sid, *args, **kwargs):
    await AuthXSocket.emit('lobby', 'User left')

Working with distributed applications

When working with distributed applications, it is often necessary to access the functionality of the Socket.IO from multiple processes. As a solution to the above problems, the Socket.IO server can be configured to connect to a message queue such as Redis or RabbitMQ, to communicate with other related Socket.IO servers or auxiliary workers.

Refer this link for more details using-a-message-queue


import socketio
from fastapi import FastAPI
from authx import AuthXSocket

app = FastAPI()

redis_manager = socketio.AsyncRedisManager('redis://')

socket_manager = AuthXSocket(app=app, client_manager=redis_manager)

What's Changed

  • chore(ref): Improve API and refactor users management code by @yezz123 in #222
  • chore: Fix Issue of Missing requirements by @yezz123 in #225
  • chore(deps): update dependencies by @yezz123 in #233
  • 🔧 change domain from .codes to .me by @yezz123 in #235
  • chore(feat): support SocketIO in authx ✨ by @yezz123 in #234

Full Changelog: 0.4.0...0.5.0