1

Suppose I have two JIDs:

  • JID 1: bob@example.com
  • JID 2 room@chat.example.com

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?

unor
  • 92,415
  • 26
  • 211
  • 360
Locke
  • 39
  • 4

2 Answers2

2

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.

legoscia
  • 39,593
  • 22
  • 116
  • 167
Joe Hildebrand
  • 10,354
  • 2
  • 38
  • 48
0

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

roomname@conference.example.com/username
unor
  • 92,415
  • 26
  • 211
  • 360
Mark S
  • 869
  • 6
  • 11