agsXMPP分析:agsXMPP Namespace
本篇简要介绍了agsXMPP类库的agsXMPP命名空间下的类。
该命名空间下有以下几个类:
Icon |
Type |
Description |
|
用于输出唯一的Message Id |
|
|
|
|
|
用于创建及处理XMPP Id |
|
|
|
|
|
Grabber的描述汇总 |
|
|
|
|
|
|
|
|
XmppClient的描述汇总 |
|
|
使用该类编写与Jabber/XMPP服务器连接的组件 |
|
|
抽象基类XmppConnection |
它们均继承自Object基类。所以都具有Equals(Object)、Finalize()、GetHashCode()、GetType()、MemberwiseClone()及ToString()方法。
Id类有以下几个主要的成员:
Icon |
Member |
Description |
|
构造函数 |
|
|
获得下一个Id |
|
|
在移动设备上节省带宽,可以将prefix设置为null,这也可能优化带宽的使用情况 |
|
|
将id计数器重置为agsXmpp_1 |
|
|
Id的类型 |
Jid类实现了IComparable接口,它有以下几个主要成员:
Icon |
Member |
Description |
|
用string创建一个新JID,user@server/Resource、user@server |
|
|
三个参数分别为user (String) 、server (String) 和resource (String) |
|
|
仅bare Jid (user@server). |
|
|
|
|
|
缺省的比较完整的Jid(Overrides Object.Equals(Object)) |
|
|
|
|
|
(Overrides Object.GetHashCode()) |
|
|
解析完整的Jid |
|
|
仅Resource字段,Null表示无 |
|
|
仅Server |
|
|
(Overrides Object.ToString()) |
|
|
仅User |
PacketGrabber类有以下两个主要成员:
Icon |
Member |
Description |
|
构造函数 |
|
|
|
MessageGrabber类继承了PacketGrabber,有以下几个主要成员:
Icon |
Member |
Description |
|
构造函数 |
|
|
参数分别为jid (Jid) comparer (IComparer) cb (MessageCB) cbArg (Object) |
|
|
jid (Jid) cb (MessageCB) cbArg (Object) |
|
|
(继承自PacketGrabber) |
|
|
移除待处理的请求。这在回拨的资源被破坏与我们不再对结果敢兴趣时非常有用 |
PresenceGrabber类也继承了PacketGrabber,有以下几个主要成员:
Icon |
Member |
Description |
|
构造函数 |
|
|
参数分别为jid (Jid) comparer (IComparer) cb (PresenceCB) cbArg (Object) |
|
|
jid (Jid) cb (PresenceCB) cbArg (Object) |
|
|
(继承自PacketGrabber) |
|
|
移除待处理的请求。这在回拨的资源被破坏与我们不再对结果敢兴趣时非常有用 |
Uri类中有较多的静态字段:
Icon |
Member |
Description |
|
构造函数 |
|
|
|
|
|
|
|
|
JEP-0065 SOCKS5 bytestreams http://jabber.org/protocol/bytestreams |
|
|
JEP-0085 Chat State Notifications http://jabber.org/protocol/chatstates |
|
|
|
|
|
Ad-Hoc Commands (http://jabber.org/protocol/commands) |
|
|
JEP-0138: Stream Compression |
|
|
|
|
|
|
|
|
Stream Compression http://jabber.org/features/compress |
|
|
|
|
|
JEP-0020: Feature Negotiation http://jabber.org/protocol/feature-neg |
|
|
GeoLoc (http://jabber.org/protocol/geoloc) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JEP-0009: Jabber-RPC |
|
|
|
|
|
|
|
|
|
|
|
Jingle http://jabber.org/protocol/jingle |
|
|
Jingle audio format description http://jabber.org/protocol/jingle/description/audio |
|
|
Jingle Info audio http://jabber.org/protocol/jingle/info/audio; |
|
|
|
|
|
Jivesoftware asterisk-im extension (http://jivesoftware.com/xmlns/phone); |
|
|
Multi User Chat (MUC) JEP-0045 http://jabber.org/protocol/muc |
|
|
"http://jabber.org/protocol/muc#admin |
|
|
http://jabber.org/protocol/muc#owner |
|
|
http://jabber.org/protocol/muc#user |
|
|
JEP-0172 User nickname http://jabber.org/protocol/nick |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JEO-0095 http://jabber.org/protocol/si |
|
|
JEO-0096 http://jabber.org/protocol/si/profile/file-transfer |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jabber:x:data |
|
|
|
|
|
|
|
|
JEP-0144 Roster Item Exchange |
|
|
|
|
|
JEP-0071: XHTML-IM (http://jivesoftware.com/xmlns/phone) |
XmppConnection类作为抽象基类提供了较多的成员实现:
Icon |
Member |
Description |
|
构造函数 |
|
|
带Socket类型参数 |
|
|
|
|
|
读取在线ClientSocket属性,返回连接使用的Socket对象 |
|
|
结束流 |
|
|
设置/读取所连接的服务器 |
|
|
Equals(Object) |
Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
|
Finalize() |
Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) |
|
错误时引发 |
|
|
读取XML时引发 |
|
|
写XML时引发 |
|
|
GetHashCode() |
Serves as a hash function for a particular type. GetHashCode() is suitable for use in hashing algorithms and data structures like a hash table. (Inherited from Object.) |
|
GetType() |
Gets the Type of the current instance. (Inherited from Object.) |
|
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object.) |
|
错误事件 |
|
|
从Socket接收到数据时的事件 |
|
|
接收到XML数据包或文本时的事件。 这不是winsock事件。事件由XML解析器产生 |
|
|
要发送的数据传送到socket时的事件 |
|
|
在Socket中写入XML或Text时的事件。这也包括保活的数据包 (a single space) |
|
|
这个事件仅通告XmppConnection当前的状态 |
|
|
|
|
|
连接的远端服务器的端口号 |
|
|
通过XmppConnection发送XML元素 |
|
|
通过XmppConnection发送XML字符串 |
|
|
连接的远端服务器的域或IP地址 |
|
|
启动socket连接 |
|
|
参数为Server、Port |
|
|
用于连接的socket类型 |
|
|
断开连接 |
|
|
Socket连接时引发 |
|
|
Socket断开时引发 |
|
|
Socket发生错误时引发 |
|
|
Socket接收到数据时引发 |
|
|
访问/设置当前XMPP XML-Stream的ID |
|
|
访问/设置流使用的解析器 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
在使用不带SASL和流特性的旧Jabber协议时设置为null |
|
|
ToString() |
Returns a String that represents the current Object. (Inherited from Object.) |
|
访问/设置连接状态 |
XmppClientConnection继承自XmppConnection
Icon |
Member |
Description |
|
构造函数 |
|
|
带Socket类型 |
|
|
带Server参数 |
|
|
带Server及Port参数 |
|
|
已被服务器确认?这是只读的,且由类库设置 |
|
|
如果设置为true,在成功登陆后会自动请求代理。如果不用代理,就将其设置为false,或者我们人工设置 |
|
|
(Inherited from XmppConnection.) |
|
|
如果设置为true,在成功登陆后会自动请求Roster (联系人列表)。如果不想接收联系人列表则将其设置为false,或者人工设置。要节省带宽,可以考虑将联系人列表放入缓存文件,这样就不用每次登录都接收一次联系人列表。 |
|
|
资源是否被绑定了?这是只读的,且由类库设置 |
|
|
更改密码。只能在使用SSL或TLS连接时才能使用此函数,因为密码以明文形式通过连接发送 |
|
|
The prefered Client Language Attribute |
|
|
Read Online Property ClientSocket returns the SOcket object used for this connection (Inherited from XmppConnection.) |
|
|
Send the end of stream (Inherited from XmppConnection.) |
|
|
(Inherited from XmppConnection.) |
|
|
(Inherited from XmppConnection.) |
|
|
(Inherited from XmppConnection.) |
|
|
(Inherited from XmppConnection.) |
|
|
|
|
|
发送保持活动状态(for NAT) |
|
|
保持数据包活动状态的时间间隔,以秒计。默认值为120 |
|
|
|
|
|
我们的XMPP ID。由Username、Server和 Resource属性组成(user@server/resourcee) |
|
|
This event is raised when a response to an agents query which could contain multiple agentitems. Normally you show the items in a GUI. This event could be used to resume the suspended userinterface. |
|
|
This event returns always a single AgentItem from a agents query result. This is from the old jabber protocol. Instead of agents Disco (Service Discovery) should be used in modern application. But still lots of servers use Agents. |
|
|
This event is raised when a response to an agents query which could contain multiple agentitems. Normally you show the items in a GUI. This event could be used to suspend the UI for faster drawing. |
|
|
Event that occurs on authentication errors e.g. wrong password, user doesnt exist etc... |
|
|
This event occurs after the resource was binded |
|
|
|
|
|
(Inherited from XmppConnection.) |
|
|
|
|
|
We are authenticated to the server now. |
|
|
We received a message. This could be a chat message, headline, normal message or a groupchat message. There are also XMPP extension which are embedded in messages. e.g. X-Data forms. |
|
|
This event ets fired after a ChangePassword Request was successful |
|
|
We received a presence from a contact or chatroom. Also subscriptions is handles in this event. |
|
|
Data received from the Socket (Inherited from XmppConnection.) |
|
|
a XML packet or text is received. This are no winsock events. The Events get generated from the XML parser (Inherited from XmppConnection.) |
|
|
This event gets fired after a new account is registered |
|
|
Event that occurs on registration errors |
|
|
This event is fired when we get register information. You ca use this event for custom registrations. |
|
|
This event is raised when a response to a roster query is received. It notifies you that all RosterItems (contacts) are received now. When this event occurs you could Resume the GUI and show the normal mousepointer again. |
|
|
This event is raised when a response to a roster query is received. This event always contains a single RosterItem. e.g. you have 150 friends on your contact list, then this event is called 150 times. |
|
|
This event is raised when a response to a roster query is received. The roster query contains the contact list. This lost could be very large and could contain hundreds of contacts. The are all send in a single XML element from the server. Normally you show the contact list in a GUI control in you application (treeview, listview). When this event occurs you couls Suspend the GUI for faster drawing and show change the mousepointer to the hourglass |
|
|
|
|
|
|
|
|
Event occurs on Socket Errors |
|
|
Data was sent to the socket for sending (Inherited from XmppConnection.) |
|
|
XML or Text is written to the Socket this includes also the keep alive packages (a single space) (Inherited from XmppConnection.) |
|
|
This event just informs about the current state of the XmppConnection (Inherited from XmppConnection.) |
|
|
This event occurs on registration errors |
|
|
打开与XMPP服务器的连接,进行服务器认证。该方法是异步的,不用设想当它返回结果时我们已经连接上了。我们必须等待OnLogin事件 |
|
|
(Inherited from XmppConnection.) |
|
|
重载。带有username、password参数
|
|
|
重载。带有username、password、priority参数 |
|
|
重载。带有username、password、resource参数 |
|
|
重载。带有username、password、resource、priority参数 |
|
|
XMPP服务器认证使用的password |
|
|
The Port of the remote server for the connection (Inherited from XmppConnection.) |
|
|
|
|
|
|
|
|
与presence信息包一同发送的此连接的优先级。The OPTIONAL priority element contains non-human-readable XML character data that specifies the priority level of the resource. The value MUST be an integer between -128 and +127. If no priority is provided, a server SHOULD consider the priority to be zero. |
|
|
程序是否要在服务器注册新账号 |
|
|
请求代理 |
|
|
请求联系人列表 |
|
|
the resource for this connection each connection to the server with the same jid needs a unique resource |
|
|
联系人列表管理器,参见RosterManager |
|
|
Send a xml element over the XmppConnection (Inherited from XmppConnection.) |
|
|
Send a xml string over the XmppConnection (Inherited from XmppConnection.) |
|
|
发送我们的Presence信息,此信息包由Status、 Show、Priority组成 |
|
|
domain or ip-address of the remote server for the connection (Inherited from XmppConnection.) |
|
|
服务器决定使用的语言 |
|
|
显示(状态)类型。参见ShowType枚举 |
|
|
Starts connecting of the socket (Inherited from XmppConnection.) |
|
|
(Inherited from XmppConnection.) |
|
|
(Inherited from XmppConnection.) |
|
|
(Inherited from XmppConnection.) |
|
|
(Overrides XmppConnection.SocketOnConnect(Object).) |
|
|
(Overrides XmppConnection.SocketOnDisconnect(Object).) |
|
|
(Overrides XmppConnection.SocketOnError(Object, Exception).) |
|
|
随同presence信息包发送的status信息。在我们更新了我们的presence信息时需要调用SendMyPresence方法 |
|
|
the id of the current xmpp xml-stream (Inherited from XmppConnection.) |
|
|
(Inherited from XmppConnection.) |
|
|
(Inherited from XmppConnection.) |
|
|
(Overrides XmppConnection.StreamParserOnStreamElement(Object, Node).) |
|
|
(Overrides XmppConnection.StreamParserOnStreamEnd(Object, Node).) |
|
|
(Overrides XmppConnection.StreamParserOnStreamError(Object, Exception).) |
|
|
(Overrides XmppConnection.StreamParserOnStreamStart(Object, Node).) |
|
|
Set to null for old Jabber Protocol without SASL andstream features (Inherited from XmppConnection.) |
|
|
是否压缩流来节省带宽?这不能同StartTLS一起使用,因为TLS已经进行了压缩 (see RFC 2246, www.ietf.org/rfc/rfc2246.txt) |
|
|
XMPP服务器认证使用的username |
|
|
在连接中使用"old style" SSL (Port 5223). |
|
|
服务器支持的情况下在连接中使用Start-TLS。在使用此特性前确保UseSSL设置为 |
XmppComponentConnection类(略)
获取更具体的library信息,可以访问Namespaces overview