Project

General

Profile

There is no ability to limit max number of resources for single occupant

Igor Khomenko
Added 6 months ago

Hi there,

I found there is no ability to limit max number of resources for single occupant.
It means a single occupant can join a particular room from unlimited devices by the same nickname.

With this issue I found the following bottlenecks in Tigase code:

Bottlenecks

1) When a user joins a room - we send a presence wrapper back to him containing all current available resources for this nickname. Every time we do a 'for' loop on unlimited resources here.

https://tigase.tech/projects/tigase-muc/repository/revisions/master/entry/src/main/java/tigase/muc/modules/PresenceModule.java#L73

2) Every time a user joins/leaves room - we re-calculate the best presence for him
And we also do a 'while' loop on unlimited resources here.

https://tigase.tech/projects/tigase-muc/repository/revisions/master/entry/src/main/java/tigase/muc/PresenceStore.java#L204

What I propose (alternatives)
1) Introduce new room config: muc#roomconfig_maxresources and use it to limit the max number of single occupant's resources
2) Introduce new config to manage what we should send back to user when he joins a room: a presence wrapper with all current available resources of this nickname (what we have now) OR only current joining resource. E.g. we can do it as a part of PresenceModuleNoBroadcast class.

Also,
I propose to optimize a PresenceStore.intGetBestPresence method for a case when we use PREFERE_LAST. We can omit that 'while' loop because presence.lastUpdated is never changed. We can introduce a HashMap with the latest presence for each occupant and access it directly.

Thanks, let me know if it makes sense


Replies (3)

Avatar?id=6098&size=32x32

Added by Bartosz Malkowski TigaseTeam 6 months ago

You're right.
We have to think what solution is the best.
Thanks for your report

#6734

Avatar?id=6098&size=32x32

Added by Bartosz Malkowski TigaseTeam 6 months ago

I added muc#roomconfig_maxresources.
I also made some optimization of intGetBestPresence(). But your solution works only when new resource join to room. When one of resource leaves room I have to find previous "last presence" in classic way.

(code is not comited yet)

Avatar?id=6098&size=32x32

Added by Bartosz Malkowski TigaseTeam 6 months ago

Code is commited, task is updated.

    (1-3/3)