Skip to content

Commit 7d4a1a7

Browse files
committed
fixed export
1 parent b010303 commit 7d4a1a7

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

ellar/socket_io/__init__.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
1+
try:
2+
import socketio # noqa
3+
except Exception: # pragma: no cover
4+
raise Exception("socketio package is required. Use `pip install socketio`.")
5+
6+
from .decorators import (
7+
WebSocketGateway,
8+
on_connected,
9+
on_disconnected,
10+
subscribe_message,
11+
)
112
from .factory import GatewayRouterFactory
213
from .responses import WsResponse
14+
from .testing import TestGateway
315

4-
__all__ = ["WsResponse", "GatewayRouterFactory"]
16+
__all__ = [
17+
"WsResponse",
18+
"GatewayRouterFactory",
19+
"on_disconnected",
20+
"on_connected",
21+
"subscribe_message",
22+
"WebSocketGateway",
23+
"TestGateway",
24+
]

ellar/socket_io/decorators/gateway.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,11 @@ def WebSocketGateway(
5151
kwargs.setdefault("async_mode", "asgi")
5252
kwargs.setdefault("cors_allowed_origins", "*")
5353

54-
_path = path
55-
56-
if path and isinstance(path, type):
57-
_path = "/socket.io"
58-
5954
def _decorator(cls: t.Type) -> t.Type:
55+
assert path == "" or path.startswith("/"), "Routed paths must start with '/'"
6056
_kwargs = AttributeDict(
6157
socket_init_kwargs=dict(kwargs),
62-
path=_path,
58+
path=path,
6359
name=name,
6460
include_in_schema=False,
6561
)
@@ -105,5 +101,7 @@ def _decorator(cls: t.Type) -> t.Type:
105101
return _gateway_type
106102

107103
if callable(path):
108-
return _decorator(path) # type:ignore[arg-type]
104+
func = path
105+
path = "/socket.io"
106+
return _decorator(func) # type:ignore[arg-type]
109107
return _decorator

0 commit comments

Comments
 (0)