mirror of
https://github.com/rommapp/romm.git
synced 2026-01-22 03:55:28 +08:00
Similar to how `engineio` provides a JSON-compatible module, this change adds a custom JSON encoder with support for additional types. Changing SocketIO's JSON module fixes the encoding issue when the scanning process tried to send a datetime, failing and the frontend not displaying the scanned game (commonly, when it had sibling games)
23 lines
598 B
Python
23 lines
598 B
Python
import socketio # type: ignore
|
|
from config import REDIS_URL
|
|
from utils import json as json_module
|
|
|
|
|
|
class SocketHandler:
|
|
def __init__(self) -> None:
|
|
self.socket_server = socketio.AsyncServer(
|
|
cors_allowed_origins="*",
|
|
async_mode="asgi",
|
|
json=json_module,
|
|
logger=False,
|
|
engineio_logger=False,
|
|
client_manager=socketio.AsyncRedisManager(str(REDIS_URL)),
|
|
)
|
|
|
|
self.socket_app = socketio.ASGIApp(
|
|
self.socket_server, socketio_path="/ws/socket.io"
|
|
)
|
|
|
|
|
|
socket_handler = SocketHandler()
|