diff options
author | fiaxh <git@lightrise.org> | 2021-12-20 19:44:15 +0100 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2021-12-22 20:48:48 +0100 |
commit | ff4e2540ae3bfab6873beb7e03ef5c6a5b9da1da (patch) | |
tree | d0a3cf2bd082163dd2f31e1b7aa38b8ac6939f9b /xmpp-vala/src | |
parent | 8e99ed1e9c19beef2536880c7d46505ec18e44c1 (diff) | |
download | dino-ff4e2540ae3bfab6873beb7e03ef5c6a5b9da1da.tar.gz dino-ff4e2540ae3bfab6873beb7e03ef5c6a5b9da1da.zip |
xmpp-vala: Fix muji issues when waiting for peer to prepare
Diffstat (limited to 'xmpp-vala/src')
-rw-r--r-- | xmpp-vala/src/module/xep/0272_muji.vala | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/xmpp-vala/src/module/xep/0272_muji.vala b/xmpp-vala/src/module/xep/0272_muji.vala index 290c4fab..2bdc068e 100644 --- a/xmpp-vala/src/module/xep/0272_muji.vala +++ b/xmpp-vala/src/module/xep/0272_muji.vala @@ -19,8 +19,9 @@ namespace Xmpp.Xep.Muji { if (result == null || result.nick == null) return null; debug(@"[%s] MUJI joining as %s done", stream.get_flag(Bind.Flag.IDENTITY).my_jid.to_string(), group_call.our_nick); + // Determine all participants that have finished preparation. Those are the ones we have to initiate the call with. Gee.List<Presence.Stanza> other_presences = yield wait_for_preparing_peers(stream, muc_jid); - var other_resources = new ArrayList<Jid>(); + var finished_real_jids = new ArrayList<Jid>(Jid.equals_func); foreach (Presence.Stanza presence in other_presences) { if (presence.stanza.get_deep_subnode(NS_URI + ":muji", NS_URI + ":preparing") != null) continue; Jid? real_jid = stream.get_flag(Muc.Flag.IDENTITY).get_real_jid(presence.from); @@ -28,10 +29,11 @@ namespace Xmpp.Xep.Muji { warning("Don't know the real jid for %s", presence.from.to_string()); continue; } - other_resources.add(real_jid); + finished_real_jids.add(real_jid); } - group_call.peers_to_connect_to.add_all(other_resources); + group_call.peers_to_connect_to.add_all(finished_real_jids); + // Build+send our own MUJI presence StanzaNode muji_node = new StanzaNode.build("muji", NS_URI).add_self_xmlns(); foreach (string media in video ? new string[] { "audio", "video" } : new string[] { "audio" }) { @@ -64,12 +66,12 @@ namespace Xmpp.Xep.Muji { private async Gee.List<Presence.Stanza> wait_for_preparing_peers(XmppStream stream, Jid muc_jid) { var promise = new Promise<Gee.List<Presence.Stanza>>(); - ArrayList<Jid> preparing_peers = new ArrayList<Jid>(); + ArrayList<Jid> preparing_peers = new ArrayList<Jid>(Jid.equals_func); Gee.List<Presence.Stanza> presences = get_other_presences(stream, muc_jid); foreach (Presence.Stanza presence in presences) { - StanzaNode? preparing_node = presence.stanza.get_deep_subnode(NS_URI + "muji", NS_URI + ":preparing"); + StanzaNode? preparing_node = presence.stanza.get_deep_subnode(NS_URI + ":muji", NS_URI + ":preparing"); if (preparing_node != null) { preparing_peers.add(presence.from); } @@ -81,8 +83,6 @@ namespace Xmpp.Xep.Muji { return presences; } - - GroupCall group_call = stream.get_flag(Flag.IDENTITY).calls[muc_jid]; group_call.waiting_for_finish_prepares[promise] = preparing_peers; @@ -201,10 +201,13 @@ namespace Xmpp.Xep.Muji { } private void on_jid_finished_preparing(XmppStream stream, Jid jid, GroupCall group_call) { + debug("Muji peer finished preparing %s", jid.to_string()); foreach (Promise<Gee.List<Presence.Stanza>> promise in group_call.waiting_for_finish_prepares.keys) { + debug("Waiting for finish prepares %i", group_call.waiting_for_finish_prepares[promise].size); Gee.List<Jid> outstanding_prepares = group_call.waiting_for_finish_prepares[promise]; if (outstanding_prepares.contains(jid)) { outstanding_prepares.remove(jid); + debug("Waiting for finish prepares %i", group_call.waiting_for_finish_prepares[promise].size); if (outstanding_prepares.is_empty) { Gee.List<Presence.Stanza> presences = get_other_presences(stream, jid.bare_jid); @@ -252,7 +255,7 @@ namespace Xmpp.Xep.Muji { public class GroupCall { public string our_nick; public Jid muc_jid; - public ArrayList<Jid> peers_to_connect_to = new ArrayList<Jid>(); + public ArrayList<Jid> peers_to_connect_to = new ArrayList<Jid>(Jid.equals_func); public ArrayList<Jid> peers = new ArrayList<Jid>(Jid.equals_func); public HashMap<Jid, Jid> real_jids = new HashMap<Jid, Jid>(Jid.hash_func, Jid.equals_func); public HashMap<Promise, Gee.List<Jid>> waiting_for_finish_prepares = new HashMap<Promise, Gee.List<Jid>>(); |