fix: SocketIO JSON dumps with sane defaults

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)
This commit is contained in:
Michael Manganiello
2025-01-12 00:25:35 -03:00
parent 8872161145
commit d837070ad0
2 changed files with 31 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
import socketio # type: ignore
from config import REDIS_URL
from utils import json as json_module
class SocketHandler:
@@ -7,6 +8,7 @@ class SocketHandler:
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)),