Registering the event handlers and fixing the examples.
This commit is contained in:
@@ -38,7 +38,7 @@ async def offer(request: dict, background_tasks: BackgroundTasks):
|
|||||||
pipecat_connection = SmallWebRTCConnection(ice_servers)
|
pipecat_connection = SmallWebRTCConnection(ice_servers)
|
||||||
await pipecat_connection.initialize(sdp=request["sdp"], type=request["type"])
|
await pipecat_connection.initialize(sdp=request["sdp"], type=request["type"])
|
||||||
|
|
||||||
@pipecat_connection.on("closed")
|
@pipecat_connection.event_handler("closed")
|
||||||
async def handle_disconnected(webrtc_connection: SmallWebRTCConnection):
|
async def handle_disconnected(webrtc_connection: SmallWebRTCConnection):
|
||||||
logger.info(f"Discarding peer connection for pc_id: {webrtc_connection.pc_id}")
|
logger.info(f"Discarding peer connection for pc_id: {webrtc_connection.pc_id}")
|
||||||
pcs_map.pop(webrtc_connection.pc_id, None)
|
pcs_map.pop(webrtc_connection.pc_id, None)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ async def offer(request: dict, background_tasks: BackgroundTasks):
|
|||||||
pipecat_connection = SmallWebRTCConnection()
|
pipecat_connection = SmallWebRTCConnection()
|
||||||
await pipecat_connection.initialize(sdp=request["sdp"], type=request["type"])
|
await pipecat_connection.initialize(sdp=request["sdp"], type=request["type"])
|
||||||
|
|
||||||
@pipecat_connection.on("closed")
|
@pipecat_connection.event_handler("closed")
|
||||||
async def handle_disconnected(webrtc_connection: SmallWebRTCConnection):
|
async def handle_disconnected(webrtc_connection: SmallWebRTCConnection):
|
||||||
logger.info(f"Discarding peer connection for pc_id: {webrtc_connection.pc_id}")
|
logger.info(f"Discarding peer connection for pc_id: {webrtc_connection.pc_id}")
|
||||||
pcs_map.pop(webrtc_connection.pc_id, None)
|
pcs_map.pop(webrtc_connection.pc_id, None)
|
||||||
|
|||||||
@@ -38,6 +38,19 @@ class SmallWebRTCConnection(BaseObject):
|
|||||||
self._connect_invoked = False
|
self._connect_invoked = False
|
||||||
self._initialize()
|
self._initialize()
|
||||||
|
|
||||||
|
# Register supported handlers. The user will only be able to register
|
||||||
|
# these handlers.
|
||||||
|
self._register_event_handler("appMessage")
|
||||||
|
self._register_event_handler("track-started")
|
||||||
|
self._register_event_handler("track-ended")
|
||||||
|
# connection states
|
||||||
|
self._register_event_handler("connecting")
|
||||||
|
self._register_event_handler("connected")
|
||||||
|
self._register_event_handler("disconnected")
|
||||||
|
self._register_event_handler("closed")
|
||||||
|
self._register_event_handler("failed")
|
||||||
|
self._register_event_handler("new")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def pc(self) -> RTCPeerConnection:
|
def pc(self) -> RTCPeerConnection:
|
||||||
return self._pc
|
return self._pc
|
||||||
|
|||||||
Reference in New Issue
Block a user