35 lines
786 B
Python
35 lines
786 B
Python
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()
|