Thursday, June 9, 2011

XMPP Framework v3 released

Version 3 of the XMPP Framework was officially released yesterday.

XMPP stands for "eXtensible Messaging and Presence Protocol". It is the protocol used by Google Talk and Facebook Chat. It can also be used for many other applications outside the realm of chat. For example, I have seen it used in P2P file transfer applications, home automation software, and even in medical applications.


Version 3 can be summarized as follows: "Massive Parallelism". It has been redesigned to take full advantage of Grand Central Dispatch (GCD). The entire stack is now thread-safe, and everything runs within its own dispatch queue.

Here are some of the highlights:

GCD Based Networking

We switched to GCDAsyncSocket. This moves all networking IO off the main thread and onto GCD. (You may recall how CocoaHTTPServer switched to GCDAsyncSocket and saw a 200% performance improvement.)

XML parsing in its own dedicated queue

Parallel network IO and XML parsing anyone?

Thread-Safe XMPPStream

XMPPStream, the heart of the XMPP Framework, is now thread-safe. So feel free to send elements from any thread you wish. This is accomplished internally by having XMPPStream run within its own dispatch queue.

If you're following along, that means parallel network IO, parallel XML parsing, and parallel xmpp stanza routing. Seeing a trend?

Every XMPPModule can now be run in its own queue

The XMPP Framework has a module plug-in system for extensions. Extensions include things like roster support, multi-user chat, publish-subscribe (PubSub), capabilities, ping, etc. Now all of these extensions can run in parallel.

And combine this parallelism with what we've mentioned so far... But wait, there's more.

Delegates can specify their own queue

All this parallelism within the framework is great. But ultimately you, the developer, are going to have to do some processing of your own. With v3 you can specify a dispatch queue to invoke your delegate methods on. So if you wanted to continue to do your xmpp processing on the main thread you could do this:

[xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];
But you can trivially parallelize your processing by creating and specifying your own queue:

[xmppStream addDelegate:self delegateQueue:myProcessingQueue];


Dedicated logging framework

And if that wasn't enough, we threw in a GCD based logging framework. It's extremely fast and powerful, but more importantly it's extremely flexible. It gives you full control over what should be logged, and where those log statements should go.

More Information on the Wiki

What's new in V3
Intro to XMPP Framework

 

3 comments:

LuXo said...

i was using your v2 version and i was glad to see the v3 version... i had to make some modifications to my code, but so far its working pretty good, and i noticed the speed increase since the first run. nice job, GCD is an awesome addition

Calvin Chen said...

How can I use PubSub right now?

I can set it to xmppStream in the past. But now what should I do with initWithServiceJID???

Charles said...

Hi!

I used the V2 version and i used to get my contact list in the callback DidReceivedPresence. But now, i can't figure out where you get the contact list in the IOS template example. Maybe i miss something (i don't really know a lot about Core Data) but i just see a Log function in this callback.

I don't really want to waste my time anymore on this so if you could help me!

Thank you!