Mercurial > libervia-backend
diff libervia/backend/plugins/plugin_xep_0166/__init__.py @ 4116:23fa52acf72c
plugin XEP-0167, XEP-0176: transport-info and ICE candidate sending are delayed if session is not active yet
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 21 Aug 2023 15:19:45 +0200 |
parents | 79ec7d7beef3 |
children | e11b13418ba6 |
line wrap: on
line diff
--- a/libervia/backend/plugins/plugin_xep_0166/__init__.py Wed Aug 16 18:33:28 2023 +0200 +++ b/libervia/backend/plugins/plugin_xep_0166/__init__.py Mon Aug 21 15:19:45 2023 +0200 @@ -55,9 +55,6 @@ NS_JINGLE : Final = "urn:xmpp:jingle:1" NS_JINGLE_ERROR : Final = "urn:xmpp:jingle:errors:1" JINGLE_REQUEST : Final = f'{IQ_SET}/jingle[@xmlns="{NS_JINGLE}"]' -STATE_PENDING : Final = "PENDING" -STATE_ACTIVE : Final = "ACTIVE" -STATE_ENDED : Final = "ENDED" CONFIRM_TXT : Final = D_( "{entity} want to start a jingle session with you, do you accept ?" ) @@ -89,6 +86,10 @@ REASON_FAILED_TRANSPORT : Final = "failed-transport" REASON_CONNECTIVITY_ERROR : Final = "connectivity-error" + STATE_PENDING : Final = "PENDING" + STATE_ACTIVE : Final = "ACTIVE" + STATE_ENDED : Final = "ENDED" + # standard actions A_SESSION_INITIATE : Final = "session-initiate" @@ -194,7 +195,7 @@ session_data = { "id": sid, - "state": STATE_PENDING, + "state": XEP_0166.STATE_PENDING, "initiator": client.jid if role == XEP_0166.ROLE_INITIATOR else peer_jid, "role": role, "local_jid": local_jid or client.jid, @@ -502,7 +503,8 @@ content_elt["creator"] = content_data["creator"] if context_elt is not None: - pass + if context_elt.parent is None: + content_elt.addChild(context_elt) elif action == XEP_0166.A_TRANSPORT_INFO: context_elt = transport_elt = content_elt.addElement( "transport", content_data["transport"].namespace @@ -1191,7 +1193,7 @@ d_list.addCallback(lambda __: iq_elt.send()) def change_state(__, session): - session["state"] = STATE_ACTIVE + session["state"] = XEP_0166.STATE_ACTIVE d_list.addCallback(change_state, session) d_list.addCallback( @@ -1279,7 +1281,7 @@ # at this point we can send the <iq/> result to confirm reception of the request client.send(xmlstream.toResponse(request, "result")) # and change the state - session["state"] = STATE_ACTIVE + session["state"] = XEP_0166.STATE_ACTIVE session["jingle_elt"] = jingle_elt await defer.DeferredList(self._call_plugins(