GLOOX 1.0 API----Framework __ Frame

Source: Internet
Author: User
Tags rfc

Reformulation CV:

2011-08-19-------------------New Text Document

2011-08-25--------------------Add XMPP website links

2011-09-02-------------------New to Gloox1.0api document Main Page translation

Personal research XMPP has been around one weeks, the basic process is to read the three-day RFC, including the rfc3290,rfc3291 two major protocols, and then the study of GLOOX1.0. XMPP In addition to these two core protocols there are many XEP extension protocols. In addition, the more mature XMPP protocol stack is the GLOOX1.0 version. The previous article has posted an RFC document, from this article began to introduce the detailed gloox, because I was also learning side records, have the master floated out of the old please enlighten.

First, post a XMPP some related resources:

XMPP official website

GLOOX Official Website---Here you can learn about Gloox's official information, develop documentation, etc.

GLOOX1.0API Documents---Individuals will be the official API documents downloaded from the entire station packaging, convenient for local viewing, we strongly recommend that you look at the main page of the document, to the entire Gloox design has a large level of understanding

RFC3920------XMPP Core Protocol

RFC3921------Instant Messaging and presence information

XMPP protocol ppt----XMPP ppt document

Let's go ahead and add it later.

--------------------------------------------------------------------------------------------------------------- ------

Gloox protocol stack is based on the so-called "observer" design pattern, if you are familiar with the "observer" design pattern or unfamiliar, but in depth to understand gloox before you can see the "Observer" mode will be good for learning gloox. The main idea is to "register" The Observer with the "observed", and what happens to the "observed", the observer will know, and further processing is to implement the "observer" in your program a number of virtual functions.

Environment, I used the vs2008, download down gloox1.0, a new project to the Gloox under the SRC directory of all. h and. cpp all loaded, and then add a project to test the Gloox, the two projects of the production directory and dependencies set well.

--------------------------------------------------------------------------------------------------------------- -------

Add: Bloggers recently learned Gloox, reread the API Main Page page, feel that the main page for beginners from the higher level to grasp the Gloox has a great help, and here is often the novice easily overlooked the most direct source of information, and decided to spend time translating. Limited to my English level, we can refer to the original English documents to view:


Introduction:

Gloox's design follows the so-called observer design pattern, meaning that everything is based on event-driven. There are two ways to use gloox than JABBER/XMPP networks------as clients or components. C + + XMPP Server Library please refer to

Note:

XMPP detailed specification (RFC 3290) of the 11.5 section requires that the data exchanged on the line can only be UTF-8 encoding, because gloox do not know what type of input data is encoded, so gloox require that the input data must be valid UTF-8 encoding.

Event Handlers:

The most important tool in Gloox is the event hanbdlers, currently, in addition to the 4 event handlers for the basic protocol services defined in the RFC, as well as many other event handlers that serve the events and additional functionality in the XEP implementation. In addition, a log processor, a generic label processor, and a connection event handler are all valid.

Usually these processors are virtual interfaces, and you can inherit them to derive a class and implement some of these virtual functions. You can then register such a subclass object into the respective implementation of the Protocol. The following is a simple example:[CPP]View plain Copy class Myclass:public Presencehandler {public://reimplemented from Presencehandler VI       rtual void handlepresence (const presence& Presence);  [...]    }; void Myclass::handlepresence (const presence& Presence) {//Extract further information from the Presence objec T}
At some point you can do this as follows:[CPP]View Plain copy otherclass::d osomething () {client* client = new Client (...);    [...]    myclass* handler = new MyClass (...);  Client->registerpresencehandler (handler); Then you can further extract the data in the section by using the many getters (that is, the member function of the get prefix) provided by the Stanza class
Now, every time you receive a presence section (a subscription section), Handlepresence is called, and the argument is the current section. You can then use the many getters provided by the Stanza class (generally a Get prefix method, which is understood to be a way to obtain stanza data) to further extract the data in the section for further processing.

Almost all event handlers work the same way as this example, followed by the use of the connection event handler (class Connectionlistener) as an example: [CPP]   View Plain copy class myclass: public connectionlistener  {     public:       virtual void onconnect ();          Virtual bool ontlsconnect (...);  };    Void myclass::onconnect ()   {     //do something when the Connection is established }    bool myclass::ontlsconnect ( const CertInfo& info) & nbsp {     //Decide whether you the certificate, examine the Certinfo structure  bsp;return true; //If you are it, otherwise return false } 
Note:

Connectionlistener is a rather peculiar interface. You will have to Connectionlistener::ontlsconnect () this interface if you want to successfully connect an enabled TLS/SSL server. Although Gloox attempts to check the server's certificate, it does not automatically trust the server. The client programmer or user must decide whether to trust this server. Whether the trust is represented by the return value of Ontlsconnect (), flase means that you do not trust the server, and the result is that the connection to the server is interrupted.

Go to eat first, come back to be continued ...

Components

A component in the JABBER/XMPP network is loaded onto the server and runs outside of the actual service software, but it has similar permissions, and the component uses the protocol described in XEP-0114 to connect and authenticate a server. Class component This protocol is supported and can be used to create a new Jabber component. The simple example is as follows:
[CPP] view Plain

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.