mirror of
https://github.com/rommapp/romm.git
synced 2026-02-18 00:27:41 +01:00
This change replaces the creation of Redis URL, from a simple string interpolation, to using `yarl.URL`. The main benefit, besides not forgetting to set all five different variables on every Redis client initialization, is that user credentials are correctly URL-encoded, if present. Up until now, if a password had special characters, it could break the generated URL. This change also introduces support for a `REDIS_SSL` setting, which allows the user to specify if the Redis connection should use SSL or not.
21 lines
530 B
Python
21 lines
530 B
Python
import socketio # type: ignore
|
|
from config import REDIS_URL
|
|
|
|
|
|
class SocketHandler:
|
|
def __init__(self) -> None:
|
|
self.socket_server = socketio.AsyncServer(
|
|
cors_allowed_origins="*",
|
|
async_mode="asgi",
|
|
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()
|