XEP-0215: management of the field expires
Add a field in `Xmpp.Xep.ExternalServiceDiscovery` to keep track of the `expires` TURN service value and use it (divided by 2) to restart periodically the external services discovery.
This commit is contained in:
parent
5784530204
commit
d6173ba850
|
@ -54,6 +54,21 @@ public class Dino.Plugins.Ice.Plugin : RootInterface, Object {
|
||||||
ice_udp_module.stun_ip = ip.to_string();
|
ice_udp_module.stun_ip = ip.to_string();
|
||||||
ice_udp_module.stun_port = 7886;
|
ice_udp_module.stun_port = 7886;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ice_udp_module.turn_service != null) {
|
||||||
|
int64? expires = ice_udp_module.turn_service.expires;
|
||||||
|
if (expires != null) {
|
||||||
|
uint delay = (uint) (expires - new DateTime.now_utc().to_unix()) / 2;
|
||||||
|
|
||||||
|
debug("Next server external service discovery in %us (because of TURN credentials' expiring time)", delay);
|
||||||
|
|
||||||
|
Timeout.add_seconds(delay, () => {
|
||||||
|
if (app.stream_interactor.connection_manager.get_state(account) != ConnectionManager.ConnectionState.CONNECTED) return false;
|
||||||
|
on_stream_negotiated.begin(account, stream);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
|
|
|
@ -25,6 +25,9 @@ namespace Xmpp.Xep.ExternalServiceDiscovery {
|
||||||
|
|
||||||
service.username = service_node.get_attribute("username", NS_URI);
|
service.username = service_node.get_attribute("username", NS_URI);
|
||||||
service.password = service_node.get_attribute("password", NS_URI);
|
service.password = service_node.get_attribute("password", NS_URI);
|
||||||
|
string? expires_str = service_node.get_attribute("expires", NS_URI);
|
||||||
|
if (expires_str != null) service.expires = DateTimeProfiles.parse_string(expires_str).to_unix();
|
||||||
|
|
||||||
service.transport = service_node.get_attribute("transport", NS_URI);
|
service.transport = service_node.get_attribute("transport", NS_URI);
|
||||||
service.name = service_node.get_attribute("name", NS_URI);
|
service.name = service_node.get_attribute("name", NS_URI);
|
||||||
string? restricted_str = service_node.get_attribute("restricted", NS_URI);
|
string? restricted_str = service_node.get_attribute("restricted", NS_URI);
|
||||||
|
@ -41,6 +44,7 @@ namespace Xmpp.Xep.ExternalServiceDiscovery {
|
||||||
|
|
||||||
public string username { get; set; }
|
public string username { get; set; }
|
||||||
public string password { get; set; }
|
public string password { get; set; }
|
||||||
|
public int64? expires { get; set; }
|
||||||
|
|
||||||
public string transport { get; set; }
|
public string transport { get; set; }
|
||||||
public string name { get; set; }
|
public string name { get; set; }
|
||||||
|
|
Loading…
Reference in a new issue