How PubNub works
As mentioned earlier, PubNub works over HTTP rather than TCP or UDP sockets. This means, the PubNub service is entirely interacted with via a web service. How does this work?
There are two URLs which form all interactions with PubNub. One is used for publishing. You request this URL and pass all information such as Publish key, Subscribe key, the channel to publish on, and the message to publish, and so on.
The other URL is used for subscribing. For the best latency, you make a request to this URL, and as soon as it returns something you make another request, and so on. Unlike most web requests, this URL has an especially long time out, and won't return anything until somebody else publishes a message on that channel. That means you generally only make requests after you receive a message.
When you request the subscribe URL, you pass a few bits of information just as with publishing, with the addition of a "time token". The first time you request it, you pass...