External Speakerstats - Stop counting if just one Paticipant inside Room

Hello Guys,

I might need a little hint on this. I tried to count the Participant in the speakerstats Object, but I dont get the Idea how this Object is passed.

Everyclient gets a local copy? If so how to stop the counter for every client if just one occupant is left?

-- Occupant left set its dominant speaker to false and update the store the
-- display name
function occupant_leaving(event)
    local room = event.room;

    if is_healthcheck_room(room.jid) then
        return;
    end

    local occupant = event.occupant;

    local speakerStatsForOccupant = room.speakerStats[occupant.jid];
    if speakerStatsForOccupant then
        speakerStatsForOccupant:setDominantSpeaker(false);

        -- set display name
        local displayName = occupant:get_presence():get_child_text(
            'nick', 'http://jabber.org/protocol/nick');
        speakerStatsForOccupant.displayName = displayName;
    end
end

I thought maybe here. If I counted participants beforehand, I could (call) all Clients to stop counting?

Any thoughts on this?

Greetings

Kian