xfirelib 0.1 review
Downloadxfirelib is a xfire protocol library created in C++. Just a small tutorial to guide you through the first steps … Connec
|
|
xfirelib is a xfire protocol library created in C++.
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
xfirelib 0.1 search tags