# HG changeset patch # User Goffi # Date 1685648254 -7200 # Node ID d107484750250011084f5e574f77048dadbd3ee9 # Parent 3d91d0aa68db471138b415f64542eb3aad71471c plugin XEP-0167: method to end a call, and corresponding signal: rel 422 diff -r 3d91d0aa68db -r d10748475025 sat/plugins/plugin_xep_0167/__init__.py --- a/sat/plugins/plugin_xep_0167/__init__.py Thu Jun 01 21:37:34 2023 +0200 +++ b/sat/plugins/plugin_xep_0167/__init__.py Thu Jun 01 21:37:34 2023 +0200 @@ -88,6 +88,14 @@ async_=True, ) host.bridge.add_method( + "call_end", + ".plugin", + in_sign="sss", + out_sign="", + method=self._call_end, + async_=True, + ) + host.bridge.add_method( "call_info", ".plugin", in_sign="ssss", @@ -98,6 +106,9 @@ "call_accepted", ".plugin", signature="sss" ) # args: session_id, answer_sdp, profile host.bridge.add_signal( + "call_ended", ".plugin", signature="sss" + ) # args: session_id, data, profile + host.bridge.add_signal( "call_info", ".plugin", signature="ssss" ) # args: session_id, info_type, extra, profile @@ -124,7 +135,6 @@ client: SatXMPPEntity, peer_jid: jid.JID, call_data: dict, - media: str = "video", ) -> None: """Temporary method to test RTP session""" contents = [] @@ -200,6 +210,34 @@ peer_metadata={}, ) + def _call_end( + self, + session_id: str, + data_s: str, + profile_key: str, + ): + client = self.host.get_client(profile_key) + return defer.ensureDeferred( + self.call_end( + client, session_id, data_format.deserialise(data_s) + ) + ) + + async def call_end( + self, + client: SatXMPPEntity, + session_id: str, + data: dict, + ) -> None: + """End a call + + @param session_id: Jingle session ID of the call + @param data: optional extra data, may be used to indicate the reason to end the + call + """ + session = self._j.get_session(client, session_id) + await self._j.terminate(client, self._j.REASON_SUCCESS, session) + # jingle callbacks def jingle_session_init( @@ -385,7 +423,7 @@ content_name: str, reason_elt: domish.Element, ) -> None: - pass + self.host.bridge.call_ended(session["id"], "", client.profile) @implementer(iwokkel.IDisco)