Project

General

Profile

Roster Management (include resource)

Krystian Wojcicki
Added over 2 years ago

I would like to extend the current roster management such that I can specify resources as well ie i can see if test@test.com/test is online/offline. I understand how the tig_pairs db works but am unsure if simply adding the resource to the jid in the tig_pairs table will suffice.

Thanks

EDIT: Maybe a bit more of a clarification if for example my friend Bob has an iphone and a computer I would like to be able to add his account twice specifying a different resource each time. Another question is how to use the UserRepository in components I always receive an error that it cannot access any repository not even the default one.


Replies (1)

Added by Wojciech Kapcia TigaseTeam over 2 years ago

(applies to 7.1.x)

Krystian Wojcicki wrote:

I would like to extend the current roster management such that I can specify resources as well ie i can see if test@test.com/test is online/offline. I understand how the tig_pairs db works but am unsure if simply adding the resource to the jid in the tig_pairs table will suffice.

EDIT: Maybe a bit more of a clarification if for example my friend Bob has an iphone and a computer I would like to be able to add his account twice specifying a different resource each time.

OK, this is a bit complicated - if you want to add a FullJID to the roster then you should be able to - in tig_pairs roster is saved in XML form. However if you would use FullJID as a key while accessing tigase.db.UserRepository then it won't work because API (and underlying storage) expects BareJID to distinguish the user.

However - seeing each resource as online/offline is inherent in the protocol and you should not use particular roster-items to make that distinction. You could, in your application, adjust the view to show all connected resources and their status.

Please also note, that in XMPP (especially recently) it's preferred to use random resources.

Another question is how to use the UserRepository in components I always receive an error that it cannot access any repository not even the default one.

How are you trying to do it? You should be able to use:

tigase.db.RepositoryFactory#getUserRepository(java.lang.String, java.lang.String, java.util.Map<java.lang.String,java.lang.String>)

For example:

String resource = System.getProperty( RepositoryFactory.GEN_USER_DB_URI_PROP_KEY );
RepositoryFactory.getUserRepository(null,resource,null);

    (1-1/1)