changeset 4070:d10748475025

plugin XEP-0167: method to end a call, and corresponding signal: rel 422
author Goffi <goffi@goffi.org>
date Thu, 01 Jun 2023 21:37:34 +0200 (18 months ago)
parents 3d91d0aa68db
children 4b842c1fb686
files sat/plugins/plugin_xep_0167/__init__.py
diffstat 1 files changed, 40 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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)