File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -108,4 +108,5 @@ def __init__(self, handle: int):
108108
109109 def __del__ (self ):
110110 if self .handle != INVALID_HANDLE :
111- assert (ffi_lib .livekit_ffi_drop_handle (c_size_t (self .handle )))
111+ ffi_lib .livekit_ffi_drop_handle (
112+ c_size_t (self .handle )) # TODO Assert
Original file line number Diff line number Diff line change @@ -64,9 +64,24 @@ def on_connect_callback(cb: proto_room.ConnectCallback):
6464 ffi_client .add_listener ('room_event' , self ._on_room_event )
6565
6666 async def close (self ):
67- self ._ffi_handle = None
68- # TODO(theomonnom): wait for ffi resp
67+ ffi_client = FfiClient ()
68+
69+ req = proto_ffi .FfiRequest ()
70+ req .disconnect .room_handle .id = self ._ffi_handle .handle
71+
72+ resp = ffi_client .request (req )
73+ future = asyncio .Future ()
74+
75+ @ffi_client .on ('disconnect' )
76+ def on_disconnect_callback (cb : proto_room .DisconnectCallback ):
77+ if cb .async_id == resp .disconnect .async_id :
78+ future .set_result (cb )
79+ ffi_client .remove_listener (
80+ 'disconnect' , on_disconnect_callback )
81+
82+ await future
6983 self ._close_future .set_result (None )
84+ self ._ffi_handle = None
7085
7186 async def run (self ):
7287 await self ._close_future
You can’t perform that action at this time.
0 commit comments