So I have a website already set up, and I need a comet server for a chat application. The site is built with twisted.web, and I want to build the comet server with twisted as well since I'm already somewhat familiar with it.
But I'm not sure how to do it. I've looked at this post and understand the mechanics in the code snippet -- but I tried it and the page takes AGES to load, and when it does, it's already full of times, and then continues adding them.
My idea of how this would work is, I would have this running as a separate process, and then run my twisted site on another. A page in the twisted site would have an ajax call to the comet server, which would wait for a response. But would that response take ages to return like the page load did?
And how would the comet server best get data from the website server? It wouldn't just poll the website or I may as well have no comet server -- would I just put an infinite loop in the GET handler for the comet server, and have the website call it and interrupt? How would the comet server and website share data? Like, how would the comet server know anything about a user's session data -- who they are, what they're waiting for, what it can send to them?
Also, I'm not sure about this, but do I have to incorporate threading into the comet server, or is it multithreaded already?