Mercurial > libervia-backend
comparison sat/plugins/plugin_xep_0260.py @ 4044:3900626bc100
plugin XEP-0166: refactoring, and various improvments:
- add models for transport and applications handlers and linked data
- split models into separate file
- some type hints
- some documentation comments
- add actions to prepare confirmation, useful to do initial parsing of all contents
- application arg/kwargs and some transport data can be initialised during Jingle
`initiate` call, this is notably useful when a call is made with transport data (this is
the call for A/V calls where codecs and ICE candidate can be specified when starting a
call)
- session data can be specified during Jingle `initiate` call
- new `store_in_session` argument in `_parse_elements`, which can be used to avoid
race-condition when a context element (<decription> or <transport>) is being parsed for
an action while an other action happens (like `transport-info`)
- don't sed `sid` in `transport_elt` during a `transport-info` action anymore in
`build_action`: this is specific to Jingle File Transfer and has been moved there
rel 419
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 15 May 2023 16:23:11 +0200 |
parents | 524856bd7b19 |
children |
comparison
equal
deleted
inserted
replaced
4043:9641ce286e07 | 4044:3900626bc100 |
---|---|
159 """Called when activation confirmation has been received from proxy | 159 """Called when activation confirmation has been received from proxy |
160 | 160 |
161 cf XEP-0260 § 2.4 | 161 cf XEP-0260 § 2.4 |
162 """ | 162 """ |
163 # now that the proxy is activated, we have to inform other peer | 163 # now that the proxy is activated, we have to inform other peer |
164 content_data = session["contents"][content_name] | |
164 iq_elt, transport_elt = self._j.build_action( | 165 iq_elt, transport_elt = self._j.build_action( |
165 client, self._j.A_TRANSPORT_INFO, session, content_name | 166 client, self._j.A_TRANSPORT_INFO, session, content_name |
166 ) | 167 ) |
168 transport_elt["sid"] = content_data["transport_data"]["sid"] | |
167 activated_elt = transport_elt.addElement("activated") | 169 activated_elt = transport_elt.addElement("activated") |
168 activated_elt["cid"] = candidate.id | 170 activated_elt["cid"] = candidate.id |
169 iq_elt.send() | 171 iq_elt.send() |
170 | 172 |
171 def _proxy_activated_eb(self, stanza_error, client, candidate, session, content_name): | 173 def _proxy_activated_eb(self, stanza_error, client, candidate, session, content_name): |
173 | 175 |
174 cf XEP-0260 § 2.4 | 176 cf XEP-0260 § 2.4 |
175 """ | 177 """ |
176 # TODO: fallback to IBB | 178 # TODO: fallback to IBB |
177 # now that the proxy is activated, we have to inform other peer | 179 # now that the proxy is activated, we have to inform other peer |
180 content_data = session["contents"][content_name] | |
178 iq_elt, transport_elt = self._j.build_action( | 181 iq_elt, transport_elt = self._j.build_action( |
179 client, self._j.A_TRANSPORT_INFO, session, content_name | 182 client, self._j.A_TRANSPORT_INFO, session, content_name |
180 ) | 183 ) |
184 transport_elt["sid"] = content_data["transport_data"]["sid"] | |
181 transport_elt.addElement("proxy-error") | 185 transport_elt.addElement("proxy-error") |
182 iq_elt.send() | 186 iq_elt.send() |
183 log.warning( | 187 log.warning( |
184 "Can't activate proxy, we need to fallback to IBB: {reason}".format( | 188 "Can't activate proxy, we need to fallback to IBB: {reason}".format( |
185 reason=stanza_error.value.condition | 189 reason=stanza_error.value.condition |
198 @param transport_data(dict): transport data | 202 @param transport_data(dict): transport data |
199 @param content_name(unicode): name of the current content | 203 @param content_name(unicode): name of the current content |
200 @param client(unicode): %(doc_client)s | 204 @param client(unicode): %(doc_client)s |
201 """ | 205 """ |
202 | 206 |
207 content_data = session["contents"][content_name] | |
203 transport_data["best_candidate"] = candidate | 208 transport_data["best_candidate"] = candidate |
204 # we need to disconnect all non selected candidates before removing them | 209 # we need to disconnect all non selected candidates before removing them |
205 for c in transport_data["peer_candidates"]: | 210 for c in transport_data["peer_candidates"]: |
206 if c is None or c is candidate: | 211 if c is None or c is candidate: |
207 continue | 212 continue |
208 c.discard() | 213 c.discard() |
209 del transport_data["peer_candidates"] | 214 del transport_data["peer_candidates"] |
210 iq_elt, transport_elt = self._j.build_action( | 215 iq_elt, transport_elt = self._j.build_action( |
211 client, self._j.A_TRANSPORT_INFO, session, content_name | 216 client, self._j.A_TRANSPORT_INFO, session, content_name |
212 ) | 217 ) |
218 transport_elt["sid"] = content_data["transport_data"]["sid"] | |
213 if candidate is None: | 219 if candidate is None: |
214 log.warning("Can't connect to any peer candidate") | 220 log.warning("Can't connect to any peer candidate") |
215 candidate_elt = transport_elt.addElement("candidate-error") | 221 candidate_elt = transport_elt.addElement("candidate-error") |
216 else: | 222 else: |
217 log.info("Found best peer candidate: {}".format(str(candidate))) | 223 log.info("Found best peer candidate: {}".format(str(candidate))) |