XMPP的地址叫做JabberID(簡寫為JID)速梗,它用來標示XMPP網(wǎng)絡(luò)中的各個XMPP實體。JID由三部分組成:domainpart担映,localpart和resourcepart此改。JID中domain是必不可少的部分茫虽。注意:domain和user部分是不分大小寫的姓赤,但是resource區(qū)分大小寫。
jid = [ localpart "@" ] domainpart [ "/" resourcepart ]
localpart = 1*(nodepoint)
;
; a "nodepoint" is a UTF-8 encoded Unicode code
; point that satisfies the Nodeprep profile of
; stringprep
;
domainpart = IP-literal / IPv4address / ifqdn
;
;the "IPv4address" and "IP-literal" rules are
; defined in RFC 3986, and the first-match-wins
;(a.k.a. "greedy") algorithm described in RFC
; 3986 applies to the matching process
;
;note well that reuse of the IP-literal rule
; from RFC 3986 implies that IPv6 addresses are
; enclosed in square brackets (i.e., beginning
;with ’[’ and ending with ’]’), which was not
;the case in RFC 3920
;
ifqdn = 1*(namepoint)
;
; a "namepoint" is a UTF-8 encoded Unicode
; code point that satisfies the Nameprep
; profile of stringprep
;
resourcepart = 1*(resourcepoint)
;
; a "resourcepoint" is a UTF-8 encoded Unicode
; code point that satisfies the Resourceprep
; profile of stringprep
;
**domainpart **:通常指網(wǎng)絡(luò)中的網(wǎng)關(guān)或者服務(wù)器仲吏。
**localpart **:通常表示一個向服務(wù)器或網(wǎng)關(guān)請求和使用網(wǎng)絡(luò)服務(wù)的實體(比如一個客戶端),當然它也能夠表示其他的實體(比如在多用戶聊天系統(tǒng)中的一個房間)不铆。
resourcepart:通常表示一個特定的會話(與某個設(shè)備)蝌焚,連接(與某個地址),或者一個附屬于某個節(jié)點ID實體相關(guān)實體的對象(比如多用戶聊天室中的一個參加者)誓斥。
JID種類有:
bare JID:user@domain.tld
full JID:user@domain.tld/resource
例子:
stpeter@jabber.org:表示服務(wù)器jabber.org上的用戶stpeter只洒。
room@service:一個用來提供多用戶聊天服務(wù)的特定的聊天室。這里 “room“ 是聊天室的名字劳坑, ”service“ 是多用戶聊天服務(wù)的主機名毕谴。
room@service/nick:加入了聊天室的用戶nick的地址。這里 “room“ 是聊天室的名字距芬, ”service“ 是多用戶聊天服務(wù)的主機名涝开,”nick“ 是用戶在聊天室的昵稱。
為了標示JID框仔,XMPP也有自己的URI舀武,例如xmpp:stpeter@jabber.org,默認規(guī)則是在JID前加xmpp:离斩。
個人認為可以把JID理解為Email地址银舱,就比較好理解了。