first commit
This commit is contained in:
34
src/utils/socketio.py
Normal file
34
src/utils/socketio.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi_socketio import SocketManager
|
||||
|
||||
class Socketio:
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def init(self, app: FastAPI):
|
||||
print("++++++++++++++++++++++++++++++++++: ", app)
|
||||
self._app = app
|
||||
self._manager = SocketManager(app=app, mount_location="/")
|
||||
|
||||
self._manager._sio.on('task_status', self.task_status)
|
||||
|
||||
async def task_status(sid, args, msg):
|
||||
print("task_status sid ++++++++++++++ ", sid)
|
||||
print("task_status args ++++++++++++++ ", args)
|
||||
print("task_status kwargs ++++++++++++++ ", msg)
|
||||
|
||||
|
||||
|
||||
def app(self):
|
||||
return self._app
|
||||
|
||||
def manager(self):
|
||||
return self._manager
|
||||
|
||||
@property
|
||||
def emit(self):
|
||||
return self._app.emit
|
||||
|
||||
|
||||
socketio = Socketio()
|
||||
Reference in New Issue
Block a user