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: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,默认规则是在JID前加xmpp:

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

中文版RFC6122
英文版RFC6122

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 要学习基于XMPP协议的IM开发,首先要熟悉XMPP协议本身。 XMPP协议的组成主要的XMPP 协议范本及当今应...
    RichieQ阅读 1,918评论 0 6
  • 一、Xmpp资源绑定 XMPP协议设计中引入了一个抽象的资源绑定过程,何为资源,如何绑定?首先这得从JID的格式设...
    AndryYu阅读 2,958评论 0 3
  • 关于XMPP最权威的讲解:http://www.jabbercn.org/RFC3920(这个才是最权威的,下面文...
    随风飘荡的小逗逼阅读 1,556评论 1 5
  • 时间过得很快,我的第一份iOS工作做的就是IM应用(选用的是XMPP),如今也忘得差不多了.利用空闲时间来重写一遍...
    飘金阅读 2,989评论 2 2
  • 清小帽子,可爱极了!这些小脑袋在春天温暖的怀抱里,迅速的往上窜,这就是笋。春天在笋里。 春天是一个绿色的世界,一个...
    橙色小蘑菇阅读 153评论 0 9