gloox官方网站---这里可以了解gloox的官方信息,开发文档等gloox1.0API文档---个人将官方的API文档整站下载下来打包,方便本地查看,强烈建议大家详细看一下文档的Main Page页,以对整个gloox的设计有一个大的层面上的理解RFC3920------XMPP核心协议RFC3921------即时消息和出席信息xmpp协议PPT----XMPP PPT文档
- class MyClass : public PresenceHandler
- {
- public:
- // reimplemented from PresenceHandler
- virtual void handlePresence(const Presence& presence );
- [...]
- };
- void MyClass::handlePresence( const Presence& presence )
- {
- // extract further information from the Presence object
- }
- class MyClass : public PresenceHandler
- {
- public:
- // reimplemented from PresenceHandler
- virtual void handlePresence( const Presence& presence );
- [...]
- };
- void MyClass::handlePresence( const Presence& presence )
- {
- // extract further information from the Presence object
- }
在某个地方你可以像下面这样做:
- OtherClass::doSomething()
- {
- Client* client = new Client( ... );
- [...]
- MyClass* handler = new MyClass( ... );
- client->registerPresenceHandler( handler );
- }
- OtherClass::doSomething()
- {
- Client* client = new Client( ... );
- [...]
- MyClass* handler = new MyClass( ... );
- client->registerPresenceHandler( handler );
- }
现在,每次接收到一个presence节(非subscription节)时,handlePresence都会被调用,参数是当前节。然后你可以使用Stanza类提供的众多getters(一般来讲是get前缀的方法,此处理解为获取stanza各数据的方法)进一步提取节中的数据以进一步处理。
- 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 )
- {
- // decide whether you trust the certificate, examine the CertInfo structure
- return true;// if you trust it, otherwise return false
- }
- 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 )
- {
- // decide whether you trust the certificate, examine the CertInfo structure
- return true; // if you trust it, otherwise return false
- }
Note:
- Component* comp = new Component( ... );
- comp->connect();
- Component* comp = new Component( ... );
- comp->connect();
- class MyClass : public ConnectionListener, PresenceHandler
- {
- public:
- void doSomething();
- virtual void handlePresence( ... );
- virtual void onConnect();
- virtual bool onTLSConnect(const CertInfo& info );
- };
- void MyClass::doSomething()
- {
- JID jid( "jid@server/resource" );
- Client* client = new Client( jid,"password" );
- client->registerConnectionListener( this );
- client->registerPresenceHandler( this );
- client->connect();
- }
- void MyClass::onConnect()
- {
- // connection established, auth done (see API docs for exceptions)
- }
- bool MyClass::onTLSConnect(const CertInfo& info )
- {
- // examine certificate info
- }
- void MyClass::handlePresence( Presence* presence )
- {
- // presence info
- }
- class MyClass : public ConnectionListener, PresenceHandler
- {
- public:
- void doSomething();
- virtual void handlePresence( ... );
- virtual void onConnect();
- virtual bool onTLSConnect( const CertInfo& info );
- };
- void MyClass::doSomething()
- {
- JID jid( "jid@server/resource" );
- Client* client = new Client( jid, "password" );
- client->registerConnectionListener( this );
- client->registerPresenceHandler( this );
- client->connect();
- }
- void MyClass::onConnect()
- {
- // connection established, auth done (see API docs for exceptions)
- }
- bool MyClass::onTLSConnect( const CertInfo& info )
- {
- // examine certificate info
- }
- void MyClass::handlePresence( Presence* presence )
- {
- // presence info
- }
- Client* client = new Client( ... );
- ConnectionTCPClient* conn = new ConnectionTCPClient( client, client->logInstance(), server, port );
- client->setConnectionImpl( conn );
- client->connect( false );
- int sock = conn->socket();
- [...]
- Client* client = new Client( ... );
- ConnectionTCPClient* conn = new ConnectionTCPClient( client, client->logInstance(), server, port );
- client->setConnectionImpl( conn );
- client->connect( false );
- int sock = conn->socket();
- [...]
有可能像下面这样获取文件描述符:
- Client* client = new Client( ... );
- client->connect( false );
- int sock = static_cast<ConnectionTCPClient*>( client->connectionImpl() )->socket();
- [...]
- Client* client = new Client( ... );
- client->connect( false );
- int sock = static_cast<ConnectionTCPClient*>( client->connectionImpl() )->socket();
- [...]
- PrivacyManager* p = new PrivacyManager( ... );
- [...]
- PrivacyListHandler::PrivacyList list;
- PrivacyItem item( PrivacyItem::TypeJid, PrivacyItem::ActionDeny,
- PrivacyItem::PacketMessage, "me@there.com" );
- list.push_back( item );
- PrivacyItem item2( PrivacyItem::TypeJid, PrivacyItem::ActionAllow,
- PrivacyItem::PacketIq, "me@example.org" );
- list.push_back( item2 );
- p->store( "myList", list );
- PrivacyManager* p = new PrivacyManager( ... );
- [...]
- PrivacyListHandler::PrivacyList list;
- PrivacyItem item( PrivacyItem::TypeJid, PrivacyItem::ActionDeny,
- PrivacyItem::PacketMessage, "me@there.com" );
- list.push_back( item );
- PrivacyItem item2( PrivacyItem::TypeJid, PrivacyItem::ActionAllow,
- PrivacyItem::PacketIq, "me@example.org" );
- list.push_back( item2 );
- p->store( "myList", list );
XEP-0012 Last Activity
XEP-0013 Flexible Offline Message Retrieval
XEP-0022 Message Events (see MessageSession for examples)
XEP-0027 Current Jabber OpenPGP Usage (see GPGSigned and GPGEncrypted )
XEP-0030 Service Discovery
XEP-0045 Multi-User Chat
XEP-0047 Used with File Transfer
XEP-0048 Bookmark Storage
XEP-0049 Private XML Storage
XEP-0050 Ad-hoc Commands
XEP-0054 vcard-temp
XEP-0060 Publish-Subscribe
XEP-0065 SOCKS5 Bytestreams , used with File Transfer and HTTP and SOCKS5 Proxy support
XEP-0066 Out of Band Data , also used with File Transfer
XEP-0077 In-Band Registration
XEP-0078 Non-SASL Authentication (automatically used if the server does not support SASL)
XEP-0079 Advanced Message Processing
XEP-0083 Nested Roster Groups (automatically used if supported by the server. see RosterManager )
XEP-0085 Chat State Notifications (see MessageSession for examples)
XEP-0091 Delayed Delivery (old spec)
XEP-0092 Software Version (integrated into Service Discovery )
XEP-0095 Stream Initiation , used with File Transfer
XEP-0096 File Transfer
XEP-0106 JID Escaping
XEP-0114 Jabber Component Protocol
XEP-0115 Entity Capabilities (used automatically internally)
XEP-0124 Bidirectional-streams Over Synchronous HTTP (BOSH)
XEP-0131 Stanza Headers and Internet Metadata
XEP-0138 Stream Compression (used automatically if gloox is compiled with zlib and if the server supports it)
XEP-0145 Annotations
XEP-0153 vCard-based Avatars
XEP-0172 User Nickname
XEP-0184 Message Receipts
XEP-0199 XMPP Ping
XEP-0203 Delayed Delivery (new spec)
XEP-0206 see BOSH
XEP-0224 Attention
XEP-0256 Last Activity in Presence