- the browser's background HTTPRequest sits in a threaded applet - someone switches on "collaboration" in his browser - the others see his name being added to the "virtual meeting" - one user drags a pointer (image) in his browser -> the pointer moves in the other browsers
See also some A's to your Q's, below. Harald
On 5/26/05, Tibi Dondera firstname.lastname@example.org wrote:
I'm trying to develop a chat application through a browser, using twisted (if possible) What I want to do:
- a user logs in the website
- he goes to the "chat page"
- he has the "classic" chat interface (sent messages, list of online
users, "send a message" field). All of these are simple "divs"
- when he sends a message, a post with the message is submitted to the
server, and registered in a temporary database table (or in memory, is there some "temporary" memory that I can use in twisted for this purpose ?)
- for refreshing the chat area, there is an open HTTPRequest in the
background. Twisted will do the following: - accept the HTTPrequest connection - keep it alive (i.e. do not send the answer, but maybe send some empty chars to force the browser to keep the connection open) - when a new message (from the other users) is available, send it to the user and close the connection.
- in the user's browser, when the connection is closed (either with a
message, or after a certain timeout, that cannot be avoided anyway), a new one will be opened, until the user quits the chat.
- Is this a plausible solution ?
- Has this already been implemented (or at least partly) ?
- Can this actually be done with twisted ?
- Can I develop this on Windows ? (production will be on linux, but
still, I prefer developing local, and currently on windows)
Hmm.. I develop "on Windows", but with a VMWare Linux server on the same laptop. Works great, but costs a bit. Should work with the server on Windows, too(?)
- Can you give me any pointers to some existing code, or where to start
? (maybe jabber for twisted ?)
Here's a few fragments from my server code -
class Servlet(resource.Resource): ... # Send queued output to browser's background listener def render_GET(self, request): self.request = request session = request.getSession() ... anything = 0 while not session.outqueue.empty(): x = session.outqueue.get() request.transport.write(x) anything = 1 if anything: request.finish() return server.NOT_DONE_YET
def render_POST(self, request): session = request.getSession() # Browser sends a dictionary as text msgDict = eval(request.args['message']) request.finish()
message = msgDict['message'] mSplit = message.split() ... # Do work here return server.NOT_DONE_YET
- How will a twisted http server coexist with my existing apache server
on the 80 port ?
Not well, I guess. I use a different port for the Twisted server.
- Must I subscribe to the twisted-http mailing list instead and ask this
question there ?
Twisted-web would be better, yes. I'm posting this one there too, with all due apologies...
Thanks for any help.
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python