agsXMPP分析:agsXMPP Namespace

本篇简要介绍了agsXMPP类库的agsXMPP命名空间下的类。

该命名空间下有以下几个类:

Icon

Type

Description

 

Id

用于输出唯一的Message Id

 

IqGrabber

 

 

Jid

用于创建及处理XMPP Id

 

MessageGrabber

 

 

PacketGrabber

Grabber的描述汇总

 

PresenceGrabber

 

 

Uri

 

 

XmppClientConnection

XmppClient的描述汇总

 

XmppComponentConnection

使用该类编写与Jabber/XMPP服务器连接的组件

 

XmppConnection

抽象基类XmppConnection

它们均继承自Object基类。所以都具有Equals(Object)Finalize()GetHashCode()GetType()MemberwiseClone()ToString()方法。

 

Id类有以下几个主要的成员:

Icon

Member

Description

 

IdNew()

构造函数

 

GetNextId()

获得下一个Id

 

Prefix

在移动设备上节省带宽,可以将prefix设置为null,这也可能优化带宽的使用情况

 

Reset()

id计数器重置为agsXmpp_1

 

Type

Id的类型

 

Jid类实现了IComparable接口,它有以下几个主要成员:

Icon

Member

Description

 

JidNew(String)

string创建一个新JIDuser@server/Resourceuser@server

 

JidNew(String, String, String)

三个参数分别为user (String) server (String) resource (String)

 

Bare

bare Jid (user@server).

 

CompareTo(Object)

 

 

Equals(Object)

缺省的比较完整的Jid(Overrides Object.Equals(Object))

 

Equals(Object, IComparer)

 

 

GetHashCode()

(Overrides Object.GetHashCode())

 

Parse(String)

解析完整的Jid

 

Resource

Resource字段,Null表示无

 

Server

Server

 

ToString()

(Overrides Object.ToString())

 

User

User

 

PacketGrabber类有以下两个主要成员:

Icon

Member

Description

 

PacketGrabberNew()

构造函数

 

Clear()

 

 

MessageGrabber类继承了PacketGrabber,有以下几个主要成员:

Icon

Member

Description

 

MessageGrabberNew(XmppClientConnection)

构造函数

 

Add(Jid, IComparer, MessageCB, Object)

参数分别为jid (Jid)

comparer (IComparer)

cb (MessageCB)

cbArg (Object)

 

Add(Jid, MessageCB, Object)

jid (Jid)

cb (MessageCB)

cbArg (Object)

 

Clear()

(继承自PacketGrabber)

 

Remove(Jid)

移除待处理的请求。这在回拨的资源被破坏与我们不再对结果敢兴趣时非常有用

 

PresenceGrabber类也继承了PacketGrabber,有以下几个主要成员:

Icon

Member

Description

 

PresenceGrabberNew(XmppClientConnection)

构造函数

 

Add(Jid, IComparer, PresenceCB, Object)

参数分别为jid (Jid)

comparer (IComparer)

cb (PresenceCB)

cbArg (Object)

 

Add(Jid, PresenceCB, Object)

jid (Jid)

cb (PresenceCB)

cbArg (Object)

 

Clear()

(继承自PacketGrabber)

 

Remove(Jid)

移除待处理的请求。这在回拨的资源被破坏与我们不再对结果敢兴趣时非常有用

 

Uri类中有较多的静态字段:

Icon

Member

Description

 

UriNew()

构造函数

 

ACCEPT

 

 

BIND

 

 

BYTESTREAMS

JEP-0065 SOCKS5 bytestreams http://jabber.org/protocol/bytestreams

 

CHATSTATES

JEP-0085 Chat State Notifications http://jabber.org/protocol/chatstates

 

CLIENT

 

 

COMMANDS

Ad-Hoc Commands (http://jabber.org/protocol/commands)

 

COMPRESS

JEP-0138: Stream Compression

 

DISCO_INFO

 

 

DISCO_ITEMS

 

 

FEATURE_COMPRESS

Stream Compression http://jabber.org/features/compress

 

FEATURE_IQ_REGISTER

 

 

FEATURE_NEG

JEP-0020: Feature Negotiation http://jabber.org/protocol/feature-neg

 

GEOLOC

GeoLoc (http://jabber.org/protocol/geoloc)

 

IQ_AGENTS

 

 

IQ_AUTH

 

 

IQ_AVATAR

 

 

IQ_BROWSE

 

 

IQ_LAST

 

 

IQ_OOB

 

 

IQ_PRIVACY

 

 

IQ_PRIVATE

 

 

IQ_REGISTER

 

 

IQ_ROSTER

 

 

IQ_RPC

JEP-0009: Jabber-RPC

 

IQ_SEARCH

 

 

IQ_TIME

 

 

IQ_VERSION

 

 

JINGLE

Jingle http://jabber.org/protocol/jingle

 

JINGLE_AUDIO_DESCRIPTION

Jingle audio format description http://jabber.org/protocol/jingle/description/audio

 

JINGLE_AUDIO_INFO

Jingle Info audio http://jabber.org/protocol/jingle/info/audio;

 

JINGLE_VIDEO_DESCRIPTION

 

 

JIVESOFTWARE_PHONE

Jivesoftware asterisk-im extension (http://jivesoftware.com/xmlns/phone);

 

MUC

Multi User Chat (MUC) JEP-0045 http://jabber.org/protocol/muc

 

MUC_ADMIN

"http://jabber.org/protocol/muc#admin

 

MUC_OWNER

http://jabber.org/protocol/muc#owner

 

MUC_USER

http://jabber.org/protocol/muc#user

 

NICK

JEP-0172 User nickname http://jabber.org/protocol/nick

 

PRIMARY

 

 

PUBSUB

 

 

PUBSUB_EVENT

 

 

PUBSUB_OWNER

 

 

ROSTER_DELIMITER

 

 

SASL

 

 

SERVER

 

 

SESSION

 

 

SHIM

 

 

SI

JEO-0095 http://jabber.org/protocol/si

 

SI_FILE_TRANSFER

JEO-0096 http://jabber.org/protocol/si/profile/file-transfer

 

STANZAS

 

 

STORAGE_AVATAR

 

 

STREAM

 

 

TLS

 

 

VCARD

 

 

X_AVATAR

 

 

X_CONFERENCE

 

 

X_DATA

jabber:x:data

 

X_DELAY

 

 

X_EVENT

 

 

X_ROSTERX

JEP-0144 Roster Item Exchange

 

XHTML

 

 

XHTML_IM

JEP-0071: XHTML-IM (http://jivesoftware.com/xmlns/phone)

 

XmppConnection类作为抽象基类提供了较多的成员实现:

Icon

Member

Description

 

XmppConnectionNew()

构造函数

 

XmppConnectionNew(SocketConnectionType)

Socket类型参数

 

AutoResolveConnectServer

 

 

ClientSocket

读取在线ClientSocket属性,返回连接使用的Socket对象

 

Close()

结束流

 

ConnectServer

设置/读取所连接的服务器

 

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.)

 

FireOnError(Object, Exception)

错误时引发

 

FireOnReadXml(Object, String)

读取XML时引发

 

FireOnWriteXml(Object, String)

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.)

 

OnError

错误事件

 

OnReadSocketData

Socket接收到数据时的事件

 

OnReadXml

接收到XML数据包或文本时的事件。 这不是winsock事件。事件由XML解析器产生

 

OnWriteSocketData

要发送的数据传送到socket时的事件

 

OnWriteXml

Socket中写入XMLText时的事件。这也包括保活的数据包 (a single space)

 

OnXmppConnectionStateChanged

这个事件仅通告XmppConnection当前的状态

 

Open(String)

 

 

Port

连接的远端服务器的端口号

 

Send(Element)

通过XmppConnection发送XML元素

 

Send(String)

通过XmppConnection发送XML字符串

 

Server

连接的远端服务器的域或IP地址

 

SocketConnect()

启动socket连接

 

SocketConnect(String, Int32)

参数为ServerPort

 

SocketConnectionType

用于连接的socket类型

 

SocketDisconnect()

断开连接

 

SocketOnConnect(Object)

Socket连接时引发

 

SocketOnDisconnect(Object)

Socket断开时引发

 

SocketOnError(Object, Exception)

Socket发生错误时引发

 

SocketOnReceive(Object, Byte[](), Int32)

Socket接收到数据时引发

 

StreamId

访问/设置当前XMPP XML-StreamID

 

StreamParser

访问/设置流使用的解析器

 

StreamParserOnError(Object, Exception)

 

 

StreamParserOnStreamElement(Object, Node)

 

 

StreamParserOnStreamEnd(Object, Node)

 

 

StreamParserOnStreamError(Object, Exception)

 

 

StreamParserOnStreamStart(Object, Node)

 

 

StreamVersion

在使用不带SASL和流特性的旧Jabber协议时设置为null

 

ToString()

Returns a String that represents the current Object.

(Inherited from Object.)

 

XmppConnectionState

访问/设置连接状态

 

XmppClientConnection继承自XmppConnection

Icon

Member

Description

 

XmppClientConnectionNew()

构造函数

 

XmppClientConnectionNew(SocketConnectionType)

Socket类型

 

XmppClientConnectionNew(String)

Server参数

 

XmppClientConnectionNew(String, Int32)

ServerPort参数

 

Authenticated

已被服务器确认?这是只读的,且由类库设置

 

AutoAgents

如果设置为true,在成功登陆后会自动请求代理。如果不用代理,就将其设置为false,或者我们人工设置

 

AutoResolveConnectServer

(Inherited from XmppConnection.)

 

AutoRoster

如果设置为true,在成功登陆后会自动请求Roster (联系人列表)。如果不想接收联系人列表则将其设置为false,或者人工设置。要节省带宽,可以考虑将联系人列表放入缓存文件,这样就不用每次登录都接收一次联系人列表。

 

Binded

资源是否被绑定了?这是只读的,且由类库设置

 

ChangePassword(String)

更改密码。只能在使用SSLTLS连接时才能使用此函数,因为密码以明文形式通过连接发送

 

ClientLanguage

The prefered Client Language Attribute

 

ClientSocket

Read Online Property ClientSocket returns the SOcket object used for this connection

(Inherited from XmppConnection.)

 

Close()

Send the end of stream

(Inherited from XmppConnection.)

 

ConnectServer

(Inherited from XmppConnection.)

 

FireOnError(Object, Exception)

(Inherited from XmppConnection.)

 

FireOnReadXml(Object, String)

(Inherited from XmppConnection.)

 

FireOnWriteXml(Object, String)

(Inherited from XmppConnection.)

 

IqGrabber

 

 

KeepAlive

发送保持活动状态(for NAT)

 

KeepAliveInterval

保持数据包活动状态的时间间隔,以秒计。默认值为120

 

MesagageGrabber

 

 

MyJID

我们的XMPP ID。由UsernameServer Resource属性组成(user@server/resourcee)

 

OnAgentEnd

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.

 

OnAgentItem

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.

 

OnAgentStart

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.

 

OnAuthError

Event that occurs on authentication errors e.g. wrong password, user doesnt exist etc...

 

OnBinded

This event occurs after the resource was binded

 

OnClose

 

 

OnError

(Inherited from XmppConnection.)

 

OnIq

 

 

OnLogin

We are authenticated to the server now.

 

OnMessage

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.

 

OnPasswordChanged

This event ets fired after a ChangePassword Request was successful

 

OnPresence

We received a presence from a contact or chatroom. Also subscriptions is handles in this event.

 

OnReadSocketData

Data received from the Socket

(Inherited from XmppConnection.)

 

OnReadXml

a XML packet or text is received. This are no winsock events. The Events get generated from the XML parser

(Inherited from XmppConnection.)

 

OnRegistered

This event gets fired after a new account is registered

 

OnRegisterError

Event that occurs on registration errors

 

OnRegisterInformation

This event is fired when we get register information. You ca use this event for custom registrations.

 

OnRosterEnd

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.

 

OnRosterItem

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.

 

OnRosterStart

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

 

OnSaslEnd

 

 

OnSaslStart

 

 

OnSocketError

Event occurs on Socket Errors

 

OnWriteSocketData

Data was sent to the socket for sending

(Inherited from XmppConnection.)

 

OnWriteXml

XML or Text is written to the Socket this includes also the keep alive packages (a single space)

(Inherited from XmppConnection.)

 

OnXmppConnectionStateChanged

This event just informs about the current state of the XmppConnection

(Inherited from XmppConnection.)

 

OnXmppError

This event occurs on registration errors

 

Open()

打开与XMPP服务器的连接,进行服务器认证。该方法是异步的,不用设想当它返回结果时我们已经连接上了。我们必须等待OnLogin事件

 

Open(String)

(Inherited from XmppConnection.)

 

Open(String, String)

重载。带有usernamepassword参数

 

 

Open(String, String, Int32)

重载。带有usernamepasswordpriority参数

 

Open(String, String, String)

重载。带有usernamepasswordresource参数

 

Open(String, String, String, Int32)

重载。带有usernamepasswordresourcepriority参数

 

Password

XMPP服务器认证使用的password

 

Port

The Port of the remote server for the connection

(Inherited from XmppConnection.)

 

PresenceGrabber

 

 

PresenceManager

 

 

Priority

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.

 

RegisterAccount

程序是否要在服务器注册新账号

 

RequestAgents()

请求代理

 

RequestRoster()

请求联系人列表

 

Resource

the resource for this connection each connection to the server with the same jid needs a unique resource

 

RosterManager

联系人列表管理器,参见RosterManager

 

Send(Element)

Send a xml element over the XmppConnection

(Inherited from XmppConnection.)

 

Send(String)

Send a xml string over the XmppConnection

(Inherited from XmppConnection.)

 

SendMyPresence()

发送我们的Presence信息,此信息包由Status ShowPriority组成

 

Server

domain or ip-address of the remote server for the connection

(Inherited from XmppConnection.)

 

ServerLanguage

服务器决定使用的语言

 

Show

显示(状态)类型。参见ShowType枚举

 

SocketConnect()

Starts connecting of the socket

(Inherited from XmppConnection.)

 

SocketConnect(String, Int32)

(Inherited from XmppConnection.)

 

SocketConnectionType

(Inherited from XmppConnection.)

 

SocketDisconnect()

(Inherited from XmppConnection.)

 

SocketOnConnect(Object)

(Overrides XmppConnection.SocketOnConnect(Object).)

 

SocketOnDisconnect(Object)

(Overrides XmppConnection.SocketOnDisconnect(Object).)

 

SocketOnError(Object, Exception)

(Overrides XmppConnection.SocketOnError(Object, Exception).)

 

Status

随同presence信息包发送的status信息。在我们更新了我们的presence信息时需要调用SendMyPresence方法

 

StreamId

the id of the current xmpp xml-stream

(Inherited from XmppConnection.)

 

StreamParser

(Inherited from XmppConnection.)

 

StreamParserOnError(Object, Exception)

(Inherited from XmppConnection.)

 

StreamParserOnStreamElement(Object, Node)

(Overrides XmppConnection.StreamParserOnStreamElement(Object, Node).)

 

StreamParserOnStreamEnd(Object, Node)

(Overrides XmppConnection.StreamParserOnStreamEnd(Object, Node).)

 

StreamParserOnStreamError(Object, Exception)

(Overrides XmppConnection.StreamParserOnStreamError(Object, Exception).)

 

StreamParserOnStreamStart(Object, Node)

(Overrides XmppConnection.StreamParserOnStreamStart(Object, Node).)

 

StreamVersion

Set to null for old Jabber Protocol without SASL andstream features

(Inherited from XmppConnection.)

 

UseCompression

是否压缩流来节省带宽?这不能同StartTLS一起使用,因为TLS已经进行了压缩 (see RFC 2246, www.ietf.org/rfc/rfc2246.txt)

 

Username

XMPP服务器认证使用的username

 

UseSSL

在连接中使用"old style" SSL (Port 5223).

 

UseStartTLS

服务器支持的情况下在连接中使用Start-TLS。在使用此特性前确保UseSSL设置为

 

XmppComponentConnection类(略)

获取更具体的library信息,可以访问Namespaces overview

原文地址:https://www.cnblogs.com/chorrysky/p/780363.html