File tree Expand file tree Collapse file tree 2 files changed +26
-8
lines changed Expand file tree Collapse file tree 2 files changed +26
-8
lines changed Original file line number Diff line number Diff line change
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
+ )
1
12
from .factory import GatewayRouterFactory
2
13
from .responses import WsResponse
14
+ from .testing import TestGateway
3
15
4
- __all__ = ["WsResponse" , "GatewayRouterFactory" ]
16
+ __all__ = [
17
+ "WsResponse" ,
18
+ "GatewayRouterFactory" ,
19
+ "on_disconnected" ,
20
+ "on_connected" ,
21
+ "subscribe_message" ,
22
+ "WebSocketGateway" ,
23
+ "TestGateway" ,
24
+ ]
Original file line number Diff line number Diff line change @@ -51,15 +51,11 @@ def WebSocketGateway(
51
51
kwargs .setdefault ("async_mode" , "asgi" )
52
52
kwargs .setdefault ("cors_allowed_origins" , "*" )
53
53
54
- _path = path
55
-
56
- if path and isinstance (path , type ):
57
- _path = "/socket.io"
58
-
59
54
def _decorator (cls : t .Type ) -> t .Type :
55
+ assert path == "" or path .startswith ("/" ), "Routed paths must start with '/'"
60
56
_kwargs = AttributeDict (
61
57
socket_init_kwargs = dict (kwargs ),
62
- path = _path ,
58
+ path = path ,
63
59
name = name ,
64
60
include_in_schema = False ,
65
61
)
@@ -105,5 +101,7 @@ def _decorator(cls: t.Type) -> t.Type:
105
101
return _gateway_type
106
102
107
103
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]
109
107
return _decorator
You can’t perform that action at this time.
0 commit comments