guv.websocket
- websocket server¶guv.websocket.
WebSocketWSGI
(handler)[source]¶Bases: object
Wraps a websocket handler function in a WSGI application.
Use it like this:
@websocket.WebSocketWSGI
def my_handler(ws):
from_browser = ws.wait()
ws.send("from server")
The single argument to the function will be an instance of
WebSocket
. To close the socket, simply return from the
function. Note that the server will log the websocket request at
the time of closure.
guv.websocket.
WebSocket
(sock, environ, version=76)[source]¶Bases: object
A websocket object that handles the details of serialization/deserialization to the socket.
The primary way to interact with a WebSocket
object is to
call send()
and wait()
in order to pass messages back
and forth with the browser. Also available are the following
properties:
__init__
(sock, environ, version=76)[source]¶Parameters: |
|
---|
close
() → None[source]¶Forcibly close the websocket; generally it is preferable to return from the handler method.