Starting to implement a signalling message to when the bot has left

This commit is contained in:
Filipi Fuchter
2025-04-10 23:02:27 -03:00
parent 5dbb5f176b
commit 6378a8ccd3
2 changed files with 10 additions and 4 deletions

View File

@@ -308,7 +308,7 @@ class SmallWebRTCClient:
if self.is_connected and not self.is_closing:
logger.info(f"Disconnecting to Small WebRTC")
self._closing = True
await self._webrtc_connection.close()
await self._webrtc_connection.disconnect()
await self._handle_client_disconnected()
async def send_message(self, frame: TransportMessageFrame | TransportMessageUrgentFrame):

View File

@@ -226,7 +226,7 @@ class SmallWebRTCConnection(BaseObject):
logger.debug("Closing old peer connection")
# removing the listeners to prevent the bot from closing
self._pc.remove_all_listeners()
await self.close()
await self._close()
# we are initializing a new peer connection in this case.
self._initialize()
@@ -271,7 +271,13 @@ class SmallWebRTCConnection(BaseObject):
else:
logger.warning("Video transceiver not found. Cannot replace video track.")
async def close(self):
async def disconnect(self):
# TODO: we should trigger something to know we are leaving
# so the client does not try to reconnect
# Like participant left
await self._close()
async def _close(self):
if self._pc:
await self._pc.close()
self._message_queue.clear()
@@ -296,7 +302,7 @@ class SmallWebRTCConnection(BaseObject):
await self._call_event_handler(state)
if state == "failed":
logger.warning("Connection failed, closing peer connection.")
await self.close()
await self._close()
# Despite the fact that aiortc provides this listener, they don't have a status for "disconnected"
# So, there is no advantage in looking at self._pc.connectionState