Galena :: xfirelib

This is a static archive of the original page - xfirelib is no longer maintained.
Navigation
Home
Board
Bug Tracker
Downloads

XFireGateway





User

You are currently not logged in.
Login
Register


0 logged in users.
21 active guests.


Project: xfirelib

Home
Board

Documentation

(Documentation@groupWiki:xfirelib) 2503 Hits - Changes: 4 - Last Change: 2006-01-28 21:21:43 by Herbert Poul (Kahless) - [ History ] [ Latest changes ]

XFirelib documentation

You may want to look at how the xfirelib testclient is implemented. but it's quite simple..

API Documentation

http://xfirelib.sphene.net/page/doc/doxygen/html/main.vm

Tutorial

Just a small tutorial to guide you through the first steps …

Connecting

xfirelib::Client *client = new xfirelib::Client();
client->connect("username","password");
client->addPacketListener( new MyOwnXFirePacketListener() );

This will allow you to log into an xfire account. after this you should be able to send and receive packets.

Listener

xfirelib uses a event/listener approach to let you know of new packets. so you need to subclass PacketListener:

class MyOwnXFirePacketListener : public xfirelib::PacketListener {
    virtual void receivedPacket( xfirelib::XFirePacket *packet );
  };

an implementation might look like:

void MyOwnXFirePacketListener::receivedPacket( xfirelib::XFirePacket *packet ) {
  // First retrieve the packet content ...
  xfirelib::XFirePacketContent *content = packet->getContent();

// Now see what kind of packet it actually is... switch(content->getPacketId()) { case XFIRE_MESSAGE_ID: // we got a message.. but by whom ? let's look into our buddylist xfirelib::BuddyListEntry buddy = client->getBuddyList()->getBuddyBySid( ((xfirelib::MessagePacket*)content)->getSid() ); std::cout << "Hey cool, we got a message from " << buddy->username << endl; break; } }

Sending Packets

To send xfire packets you simply create a new packet content packet and send it through your client object. e.g. if you want to send a message you can use the SendMessagePacket:

SendMessagePacket msg;
// msg.init is a convenience method which will convert the username to a sid for you
// (since a message requires a sid as target, not a username)
msg.init(client, "username", "Hi, how are you ? :)" );
client->send( &msg );



0 Comments
You need to be logged in to post a Comment !

Powered by Galena
This page is powered by Galena. - Get your own free "CMS" (Wiki, Board, Todolist/Buglist-Tracker)
Author of Galena: Herbert Poul - kahless+galena@sphene.net - jabber id: kahless@sphene.net - icq uin: 50647169
Page generated in 113 millisecs