Cognition of the agsXMPP

来源:互联网 发布:js代码格式化 编辑:程序博客网 时间:2024/04/29 05:13

What the XMPP protocol depict ,In fact, it is totally the exchange of the XML datas between the client and server.  Using the object-oriented thinking to describe the XML fragments as Jabber packets is the common way.  I had read some open source projects about jabber both in C# and Java,  The designers think in the same way. So is the structure. They just like carving  from the same template.

When the Socket receives data from the sender,  it all pushes to the StreamParser.  Then,StreamParser parses the  data。The method of parsing uses the mind of compiler construction principles,describing the keywords as the enumeration of the tokens. I think it will be faster than comparing strings.

As the process of parsing,  the StreamParser will trigger the following four events.

1.streamParser_OnStreamStart
2.streamParser_OnStreamEnd
3.streamParser_OnStreamElement
4.streamParser_OnStreamError

When receiving "
SEND: <stream:stream to=’capulet.com’xmlns=’jabber:client’
               xmlns:stream=’http://etherx.jabber.org/streams’> ",  StreamParser will trigger the streamParser_OnStreamStart evnet.  In responding the event we (the server) need the user to authenticate or register. 
1.authentication:
If the client want to login in at the moment, it should request the server for login-in information. 
The side of client may do as follows:
RequestLoginInfo()         asking for imformation of login-in from the server
OnGetAuthInfo()                when receiving the information, it will prepare to send the request.
OnAuthenticate()               As the response from the server , it autheticate the user whether is the member of  the server. If yes, then
RequestAgents() and RequestRoster()          ( the function is easy to kown it's meaning.)
To be continue....
 
原创粉丝点击