Re: [Paste] Re: 'wsgi.output' in environ?

Top Page
Author: Ian Bicking
Date:  
To: Paul Davis
CC: Graham Dumpleton, Paste Users
Subject: Re: [Paste] Re: 'wsgi.output' in environ?
On Sat, Jul 31, 2010 at 3:17 PM, Paul Davis <paul.joseph.davis@???>wrote:

> > I can imagine an incoming WebSocket message (first message or later
> > messages) could be represented as a WSGI request, just adding a
> connection
> > ID and cloning the HTTP headers each time. Responses could be... well,
> > that's tricky, as there's no request/response pairing. You could put in
> > something like environ['websockets.send_message']('a message to send').
> But
> > then the actual WSGI response becomes meaningless. So it's not a great
> > fit. But at least it is always initiated by the client.
>
> That's a pretty interesting idea. Though it breaks the server
> initiated message part of websockets. My orginal wsgi.upgrade was
> basically to say "this connection is no longer HTTP and the app code
> has taken responsibility for handling the connection".



The server can only initiate a message, not a connection, so the ability to
save websockets.send_message (and use whatever queuing or task process you
had to send messages) would help. In most applications you probably won't
even need another set of processes, as messages would be sent because of
something else, e.g., in a chat application a message will be sent out when
a message comes in (but across different sockets). It does seem like an
asynchronous API would be helpful in this case, as there's no reason to
block the one client in order to send out a message to other clients...
though I suppose all websocket requests will in effect be asynchronous
because the WSGI response wouldn't mean anything. I guess you also need
server-initiated close, since the request wouldn't close on its own (though
maybe require a 204 No Content response to indicate the application
understands web sockets, and otherwise simply abort).

-- 
Ian Bicking  |  http://blog.ianbicking.org

-- 
You received this message because you are subscribed to the Google Groups "Paste Users" group.
To post to this group, send email to paste-users@???.
To unsubscribe from this group, send email to paste-users+unsubscribe@???.
For more options, visit this group at http://groups.google.com/group/paste-users?hl=en.