voice-changer/server/sio/MMVC_SocketIOServer.py

24 lines
696 B
Python
Raw Normal View History

2022-12-31 10:27:18 +03:00
import socketio
from sio.MMVC_Namespace import MMVC_Namespace
from voice_changer.VoiceChangerManager import VoiceChangerManager
2023-05-04 06:29:12 +03:00
class MMVC_SocketIOServer:
_instance: socketio.AsyncServer | None = None
2022-12-31 10:27:18 +03:00
@classmethod
2024-03-18 23:52:22 +03:00
def get_instance(
cls,
voiceChangerManager: VoiceChangerManager,
allowedOrigins: list[str],
):
2023-05-04 06:34:47 +03:00
if cls._instance is None:
2024-03-18 23:52:22 +03:00
sio = socketio.AsyncServer(async_mode="asgi", cors_allowed_origins=allowedOrigins)
2022-12-31 10:27:18 +03:00
namespace = MMVC_Namespace.get_instance(voiceChangerManager)
sio.register_namespace(namespace)
cls._instance = sio
return cls._instance
return cls._instance