tags:

views:

767

answers:

2

I've made a chat that I can connect with Telnet to. My chat is currently implemented as a Twisted TCP Server. How do I transform it into a chat for the browser?

I suppose I should use a comet server (e.g. Orbited) to be able to serve static HTML and dynamic content simultaneously. Is such a comet server necessary for a fast and reliable chat?

A: 

Yeah it is! Check www.meebo.com ! They use comet as their basic platform!

Martin K.
+1  A: 

Comet is the best option without using anything special (like Flash, see below). It's a proven technology and is used by many big sites, like Gmail's chat and Facebook's chat.

The only other option you have is polling, but that can sometimes get a bit intense on the server. You basically have to weigh server load against speed - if you poll often, you get a very responsive client, but you put a lot of load on your server. Poll too little and you keep the load light but clients can only receive messages every n seconds so it can seem slow.

If you decide to poll, you could always create a "back off" system. For example, the page checks every 2 seconds to see if there are any chat messages sent. It does this 5 times and if there is nothing, it increases the delay to 3 seconds. It does this 5 times and after nothing it goes to 4 seconds..etc. When a chat message is sent it goes back down to the shortest delay.

Another option to consider that is even better is using a Flex or Flash client. This way, you can just use TCP sockets which only send data if there is any. But that's only if you really want a Flash app on your site.

ryeguy
Thanks, do I get it right that a comet server provides an interface for the chat app to send data to browser without a request?"This way, you can just use TCP sockets which only send data if there is any." - with Flash I'll be able to use the same backend application as for the Telnet, right?
Alex
You still have to make a request with Comet, but what the technology is is basically a very long poll. Your webpage will request a PHP page, but that PHP request will stay open until the server actually has data to send. This "long poll" can last minutes (as opposed to with a regular poll...(cont)
ryeguy
...which quickly checks and returns if there is nothing to send). You can see an example of this at http://www.zeitoun.net/articles/comet_and_php/start. And yes, if you choose TCP with flash, you can Telnet in, as Telnet also operates on TCP. However, you would then have to use a text-based protocol
ryeguy