@@ -127,12 +127,12 @@ def __init__(
127127 self ._cleanup_task = None
128128
129129 @self .sio .event
130- def connect (sid : str , environ : dict ):
131- self ._on_connect (sid , environ )
130+ async def connect (sid : str , environ : dict ):
131+ await self ._on_connect (sid , environ )
132132
133133 @self .sio .event
134- def disconnect (sid : str ):
135- self ._on_disconnect (sid )
134+ async def disconnect (sid : str ):
135+ await self ._on_disconnect (sid )
136136
137137 @self .sio .on (RPC_CALL_EVENT )
138138 async def on_rpc_call (sid : str , data : Any ):
@@ -222,19 +222,20 @@ async def _on_rpc_result(self, client_id: str, result: Any):
222222 else :
223223 future .set_exception (Exception (error ))
224224
225- def _on_connect (self , sid : str , environ : dict ):
225+ async def _on_connect (self , sid : str , environ : dict ):
226226 qs = parse_qs (environ .get ("QUERY_STRING" , "" ))
227227 (client_id ,) = qs .get (CLIENT_ID_QS , [None ])
228228 if not client_id :
229229 raise ConnectionRefusedError ("No clientId provided" )
230230
231231 self .clients [sid ] = client_id
232- # add to room based on client_id
233- self .sio .enter_room (sid , client_id )
234232
235- def _on_disconnect (self , sid : str ):
233+ await self .sio .enter_room (sid , client_id )
234+
235+ async def _on_disconnect (self , sid : str ):
236236 client_id = self .clients [sid ]
237- self .sio .leave_room (sid , client_id )
237+ await self .sio .leave_room (sid , client_id )
238+ await self .sio .close_room (client_id )
238239
239240 async def _on_rpc_call (self , client_id : str , data : Any ):
240241 try :
0 commit comments