XMPP的地址叫做JabberID(簡寫為JID),它用來標示XMPP網(wǎng)絡中的各個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)絡中的網(wǎng)關或者服務器。
**localpart **:通常表示一個向服務器或網(wǎng)關請求和使用網(wǎng)絡服務的實體(比如一個客戶端),當然它也能夠表示其他的實體(比如在多用戶聊天系統(tǒng)中的一個房間)。
resourcepart:通常表示一個特定的會話(與某個設備),連接(與某個地址),或者一個附屬于某個節(jié)點ID實體相關實體的對象(比如多用戶聊天室中的一個參加者)。
JID種類有:
bare JID:user@domain.tld
full JID:user@domain.tld/resource
例子:
stpeter@jabber.org:表示服務器jabber.org上的用戶stpeter。
room@service:一個用來提供多用戶聊天服務的特定的聊天室。這里 “room“ 是聊天室的名字, ”service“ 是多用戶聊天服務的主機名。
room@service/nick:加入了聊天室的用戶nick的地址。這里 “room“ 是聊天室的名字, ”service“ 是多用戶聊天服務的主機名,”nick“ 是用戶在聊天室的昵稱。
為了標示JID,XMPP也有自己的URI,例如xmpp:stpeter@jabber.org,默認規(guī)則是在JID前加xmpp:。
個人認為可以把JID理解為Email地址,就比較好理解了。