2022-12-31 12:27:38 +03:00
|
|
|
import socketio
|
|
|
|
|
|
|
|
from sio.MMVC_SocketIOServer import MMVC_SocketIOServer
|
|
|
|
from voice_changer.VoiceChangerManager import VoiceChangerManager
|
2023-03-08 03:48:50 +03:00
|
|
|
from const import getFrontendPath
|
2022-12-31 12:27:38 +03:00
|
|
|
|
2023-02-16 21:47:43 +03:00
|
|
|
|
2023-05-04 06:29:12 +03:00
|
|
|
class MMVC_SocketIOApp:
|
|
|
|
_instance: socketio.ASGIApp | None = None
|
|
|
|
|
2022-12-31 12:27:38 +03:00
|
|
|
@classmethod
|
2023-02-16 21:47:43 +03:00
|
|
|
def get_instance(cls, app_fastapi, voiceChangerManager: VoiceChangerManager):
|
2023-05-04 06:29:12 +03:00
|
|
|
if cls._instance is None:
|
2022-12-31 12:27:38 +03:00
|
|
|
sio = MMVC_SocketIOServer.get_instance(voiceChangerManager)
|
|
|
|
app_socketio = socketio.ASGIApp(
|
2023-02-16 21:47:43 +03:00
|
|
|
sio,
|
|
|
|
other_asgi_app=app_fastapi,
|
|
|
|
static_files={
|
2023-05-04 06:29:12 +03:00
|
|
|
"/assets/icons/github.svg": {
|
|
|
|
"filename": f"{getFrontendPath()}/assets/icons/github.svg",
|
|
|
|
"content_type": "image/svg+xml",
|
2023-02-16 21:47:43 +03:00
|
|
|
},
|
2023-05-04 06:29:12 +03:00
|
|
|
"/assets/icons/help-circle.svg": {
|
|
|
|
"filename": f"{getFrontendPath()}/assets/icons/help-circle.svg",
|
|
|
|
"content_type": "image/svg+xml",
|
2023-02-16 21:47:43 +03:00
|
|
|
},
|
2023-05-04 06:29:12 +03:00
|
|
|
"/assets/icons/tool.svg": {
|
|
|
|
"filename": f"{getFrontendPath()}/assets/icons/tool.svg",
|
|
|
|
"content_type": "image/svg+xml",
|
2023-04-01 21:04:11 +03:00
|
|
|
},
|
2023-05-04 06:29:12 +03:00
|
|
|
"/buymeacoffee.png": {
|
|
|
|
"filename": f"{getFrontendPath()}/assets/buymeacoffee.png",
|
|
|
|
"content_type": "image/png",
|
2023-02-16 21:47:43 +03:00
|
|
|
},
|
2023-05-04 06:29:12 +03:00
|
|
|
"": f"{getFrontendPath()}",
|
|
|
|
"/": f"{getFrontendPath()}/index.html",
|
|
|
|
},
|
2023-02-16 21:47:43 +03:00
|
|
|
)
|
2022-12-31 12:27:38 +03:00
|
|
|
|
|
|
|
cls._instance = app_socketio
|
|
|
|
return cls._instance
|
|
|
|
|
|
|
|
return cls._instance
|