Access a roster out side of a session

Submitted by Anonymous on Thu, 2010-07-22 18:40

We are limiting the number of contacts for each user. I am using a preprocess to stop the packet when the user goes over there limit. It's straightforward to check the users roster size using roster.getBuddies(session).length

checking the contacts roster size is not so straight forward as i don't have a session for them. Is there a right way to access a contacts roster? in tigase to do this?

Artur Hefczyc's picture

I would probably put the

I would probably put the logic in the JabberIqRoster plugin instead of preprocessor.
Preprocessor is called for every single packet, whereas plugin only for specific packets. Therefore preprocessor like this may affect performance.

Checking the buddy roster size requires a call to the database which is another expensive operation. If you plan to deploy large scale installation I would advice against doing so.
Anyway, this is possible by a direct call to the database. I will think about some code sample.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.