这两天我收集阅读的资料资料在此:http://delicious.com/j0sf/jabber
以下为写的笔记,若作为局域网的IM,还可以删除部分组件。
jabberd2中的五个组件,通过tcp/ip通信
* Router
* Server to Server (S2S)
* Resolver
* Session Manager (SM)
* Client to Server (C2S)
Router
监听接受其余组件的连接,并在各组件之间传递XML包
S2S
与外部的服务器通信
Resolver
解析外部服务器的地址
SM
会话管理器
主要负责:
传递消息
在线信息信息
角色名册
订阅
C2S
客户端与服务器连接
连接客户端
传递包给会话管理器
认证客户端
注册新用户
触发和SM的活动
==========================================
数据处理相关,从数据库中表的角度
active
第一次活跃的信息
Stores date/time upon which each account first became active.
authreg
注册信息相关
Contains authentication information, including username, realm and password.
disco-items
Stores persistent discovery information so that it is available for offline retrieval.
logout
离线时间
Stores JID and timestamp for most recent user log out.
motd-message
在线心情
Stores message of the day (MOTD) in XML format.
motd-times
每一次更换签名的时间
Records JID's and timestamps for receipt of MOTD.
privacy-default
Stores the name of the current list in use for a user so it can be made active on startup.
privacy-items
黑名单
Stores user privacy lists (blacklists/whitelists).
private
Provides private XML storage for uses such as user preferences or bookmarks.
queue
消息xml格式
Stores queued messages in XML format.
roster-groups
名册组
Stores user roster items only for those roster items that have an assigned group.
roster-items
名册和验证信息
Stores user roster items, including authorization status.
vacation-settings
渡假设置
Handles vacation settings, including start, end and message.
vcard
身份信息
Stores vcard information.
==================================================
客户端相关
JID
JID(Jabber identifier)是你身份标识,用以标识您的个人身份。
Streams and Stanzas
在Jabber的消息交换过程中,有两种概念比较重要的是Streams 和 Stanzas。
Streams 是Jabber客户端和其服务器之间的联通、交换消息的容器(例如GoogleTalk和gmail.com ),以 XML格式的<stream>开始,以</stream>结束。而两者之间交换的各种消息都是其他格式的XML节点(被称为 stanzas),都被包含在这个容器中,当联通的两端任何一方退出登录的时候,就发送</stream>给另外一方。比如我关闭 GoogleTalk客户端,其就会发送</stream>给gmail.com通知结束会话。
PS:这里需要强调的是stream不会出现在用户A和用户B之间,而仅仅存在于您使用的客户端和其对应的服务器端之间。
Stanzas节点包含的的就是用户A和用户B直接需要交换的消息,一般常用的有3个格式的,分别为:
1. Message
2. Presence
3. IQ
Message类的Stanzas用来在两个用户间交换消息,比如用户A(iceskysl@someserver.com/home)给用户B(1sters@someotherserver.com/home)发送一条消息“1sters… are you there?”,其包装以后的格式类似于:
<stream>
<message to=’1sters@someotherserver.com/home’>
<body>1sters… are you there?</body>
</message>
…
…
</stream> <!--注意,这个结束节点在你中断客户端连接的时候才会发送 -->
我们再来看看,这个过程是怎么样的,当用户A发送消息的时候,其消息先someserver.com,然后someserver.com看到其消息是发给
1sters@someotherserver.com/home的,于是将其传递给用户B的服务器someotherserver.com,然后,由someotherserver.com发送给用户B。
presence 类的stanza 是当用户的状态(Idle, Offline, Available, Do not disturb等等 )发生改变时发送的。
IQ (Info / Query)类的stanzas是用来查看对方信息的,比如用户A想查看用户B的信息,就会发送一个“获取消息”的IQ stanza,用户B收到后,会回一个包含用户A查询的信息的IQ stanza。
--
Sincerely,
HaveF
No comments:
Post a Comment