1
votes

Suppose I have two JIDs:

JID 2 clearly refers to the chat server, but the chat server isn't always going to have the word chat or conference in it.

Is there a way, using the Smack libraries, to tell which one is which?

2

2 Answers

2
votes

You cannot tell by looking at the JID. You have to keep enough context in a given protocol exchange to know what you are talking to.

Typically on startup, a client will send a disco#items query to the server:

<iq type='get'
    to='shakespeare.lit'
    id='items1'>
  <query xmlns='http://jabber.org/protocol/disco#items'/>
</iq>

to find all of the local services, then send a disco#info query to each of those services to find out more about the service. Once you find a MUC server:

<iq from='chat.shakespeare.lit'
    type='result'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    <identity
        category='conference'
        name='Shakespearean Chat Service'
        type='text'/>
    <feature var='http://jabber.org/protocol/muc'/>
  </query>
</iq>

you know that all of the JIDs that include this domain name (chat.shakespeare.lit in the above example) are associated with MUC rooms.

0
votes

A user JID in a MUC will (should) have the username at the end and will look like:

[email protected]/username