Skip to content
This repository was archived by the owner on Apr 4, 2024. It is now read-only.

Commit b00fbf1

Browse files
committed
Add async transport mode
1 parent c97f4cb commit b00fbf1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fastapi_socketio/socket_manager.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
from typing import Optional, Union
33
from fastapi import FastAPI
44

5+
class TransportMode(Enum):
6+
ASGI = "asgi"
7+
SANIC = "sanic"
58

69
class SocketManager:
710
"""
@@ -23,9 +26,10 @@ def __init__(
2326
mount_location: str = "/ws",
2427
socketio_path: str = "socket.io",
2528
cors_allowed_origins: Union[str, list] = '*',
29+
async_mode: str = "asgi"
2630
) -> None:
2731
# TODO: Change Cors policy based on fastapi cors Middleware
28-
self._sio = socketio.AsyncServer(async_mode="asgi", cors_allowed_origins=cors_allowed_origins)
32+
self._sio = socketio.AsyncServer(async_mode=async_mode, cors_allowed_origins=cors_allowed_origins)
2933
self._app = socketio.ASGIApp(
3034
socketio_server=self._sio, socketio_path=socketio_path
3135
)

0 commit comments

Comments
 (0)