Friday 23 November 2007

Protocol

After researching again a little into available XMPP APIs I finally decided to create my own Protocol.

The main Problem here by is the http connection. It was a little tough to find information persistent connection using http.
I had a talk with Michael Collins and he told me that it's not possible anyway as http is stateless. He recommended me to use standard Sockets. As a result I did some further research how XMPP managed to connect through http and most important: receive messages from the server.
On Wikipedia I found a solution. It uses / used two approaches. HTTP polling and HTTP binding. For HTTP binding i will have to make some more research.

Polling
Polling is very simple.It uses frequent GET and POST requests to the server and the server replies all messages which have been stored.
Binding

Binding is a little more complex. Wikipedia says, that it uses longer lived HTTP connections. I interpret it in a way, that the server sends out all messages but it won't close the connection. It could be compared with viewing a web site using a bad internet connection where the page is being loaded slowly line for line. Difficulties for this approach would appear in many ways. How tom implement it that the server will not create xxx bound connections to one client, as the connection is bound only one way. Another very important part is how to deal with time outs?

A Possible Solution

I also found out that XMPP also uses Standard Sockets - as recommended by Michael Collins. My idea is now to create a double implementation. Using standard Sockets and as an alternative HTTP if a socket connection could not be established. This would requires a good and clean implementation to avoid time loss due to unnecessary double implementation. Standard sockets for with full support how it is supposed to be and HTTP polling with a refresh rate between 1 and 20 seconds. This would slow decrease the response speed, but it would still allow a considerably good communication. As this is a quite large project I am considering HTTP binding only as an option if enough time is left in the end of the project as implementation would be unnecessary complex for the benefits in comparison to Polling. Nevertheless binding still gives enough potential should this project become a commercial success and a reduction of server load would become necessary.

File Transfer

For file transfers I would need to create separate connections. I am not 100% sure of how to implement it but the general idea is there. For legal and performance reasons all file transfers between clients would be set up using Peer to Peer socket connections. For file transfers between the server and it's clients I have two approaches in my head. One would using only HTTP GET and POST and the other would be the usage of Sockets if a socket connection exists. Which I approach I am going to take, I will have to decide when the basic communication is works.

No comments: