XMPP JID

XMPP的地址叫做JabberID(简写为JID),它用来标示XMPP网络中的各个XMPP实体。JID由三部分组成:domainpart,localpart和resourcepart。JID中domain是必不可少的部分。注意:domain和user部分是不分大小写的,但是resource区分大小写。

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 **:通常指网络中的网关或者服务器。
**localpart **:通常表示一个向服务器或网关请求和使用网络服务的实体(比如一个客户端),当然它也能够表示其他的实体(比如在多用户聊天系统中的一个房间)。
resourcepart:通常表示一个特定的会话(与某个设备),连接(与某个地址),或者一个附属于某个节点ID实体相关实体的对象(比如多用户聊天室中的一个参加者)。

JID种类有:
bare JID:[email protected]
full JID:[email protected]/resource

例子:

[email protected]:表示服务器jabber.org上的用户stpeter。
room@service:一个用来提供多用户聊天服务的特定的聊天室。这里 “room“ 是聊天室的名字, ”service“ 是多用户聊天服务的主机名。
room@service/nick:加入了聊天室的用户nick的地址。这里 “room“ 是聊天室的名字, ”service“ 是多用户聊天服务的主机名,”nick“ 是用户在聊天室的昵称。

为了标示JID,XMPP也有自己的URI,例如xmpp:[email protected],默认规则是在JID前加xmpp:

个人认为可以把JID理解为Email地址,就比较好理解了。

中文版RFC6122
英文版RFC6122

你可能感兴趣的:(XMPP JID)