服务发现,主要是查询服务器支持哪些功能,以及以目录的形式浏览上面提供的服务,比如聊天室(会议室),
一般查询流程如下
1.查询服务器上所有的条目,服务器为根(shakespeare.lit) (相当我的电脑 中,查询有哪些盘,C盘,d盘,e盘等)
<iq type='get'
from='romeo@montague.net/orchard'
to='shakespeare.lit'
id='items1'>
<query xmlns='http://jabber.org/protocol/disco#items'/>
</iq>
返回,子节点列表,在jid来区分不同条目
<iq type='result'
from='shakespeare.lit'
to='romeo@montague.net/orchard'
id='items1'>
<query xmlns='http://jabber.org/protocol/disco#items'>
<item jid='people.shakespeare.lit'
name='Directory of Characters'/>
<item jid='plays.shakespeare.lit'
name='Play-Specific Chatrooms'/>
<item jid='mim.shakespeare.lit'
name='Gateway to Marlowe IM'/>
<item jid='words.shakespeare.lit'
name='Shakespearean Lexicon'/>
<item jid='globe.shakespeare.lit'
name='Calendar of Performances'/>
<item jid='headines.shakespeare.lit'
name='Latest Shakespearean News'/>
<item jid='catalog.shakespeare.lit'
name='Buy Shakespeare Stuff!'/>
<item jid='en2fr.shakespeare.lit'
name='French Translation Service'/>
</query>
</iq>
2.在条目中查询节点(查询catalog.shakespeare.lit下的节点)(相当于在C盘中查询有哪些目录,比如 C:\,这里记路径为\*)
发送
<iq type='get'
from='romeo@montague.net/orchard'
to='catalog.shakespeare.lit'
id='items2'>
<query xmlns='http://jabber.org/protocol/disco#items'/>
</iq>
返回
<iq type='result'
from='catalog.shakespeare.lit'
to='romeo@montague.net/orchard'
id='items2'>
<query xmlns='http://jabber.org/protocol/disco#items'>
<item jid='catalog.shakespeare.lit'
node='books'
name='Books by and about Shakespeare'/>
<item jid='catalog.shakespeare.lit'
node='clothing'
name='Wear your literary taste with pride'/>
<item jid='catalog.shakespeare.lit'
node='music'
name='Music from the time of Shakespeare'/>
</query>
</iq>
这里的node为条目节点
分别为books,clothing,music三个节点
3.查询(music)子节点(查询:\music\*)
发送
<iq type='get'
from='romeo@montague.net/orchard'
to='catalog.shakespeare.lit'
id='items3'>
<query xmlns='http://jabber.org/protocol/disco#items'
node='music'/>
</iq>
返回
<iq type='result'
from='catalog.shakespeare.lit'
to='romeo@montague.net/orchard'
id='items3'>
<query xmlns='http://jabber.org/protocol/disco#items'
node='music'>
<item jid='catalog.shakespeare.lit'
node='music/A'/>
<item jid='catalog.shakespeare.lit'
node='music/B'/>
<item jid='catalog.shakespeare.lit'
node='music/C'/>
<item jid='catalog.shakespeare.lit'
node='music/D'/>
.
.
.
</query>
</iq>
就如上面这样,目录式地查询相应原地址,至于 怎么区分到底是目录 ,还是文件,还是其它的,下篇文章讲解
总结一下查询过程:
1.查询条目(我的电脑 中查询盘符)
2.查询节点(在C盘中查询有哪些文件夹)
3.继续查询节点(相当 于在文件夹下查询子文件夹)