Package core :: Module http :: Class WebSocket
[hide private]
[frames] | no frames]

Class WebSocket

source code

         object --+    
                  |    
 streams.ReadStream --+
                      |
         object --+   |
                  |   |
streams.WriteStream --+
                      |
                     WebSocket
Known Subclasses:

Encapsulates an HTML 5 Websocket.

Instances of this class are created by an HttpClient instance when a client succeeds in a websocket handshake with a server. Once an instance has been obtained it can be used to s or receive buffers of data from the connection, a bit like a TCP socket.

Instance Methods [hide private]
 
__init__(self, websocket) source code
 
write_binary_frame(self, buffer)
Write data to the websocket as a binary frame
source code
 
write_text_frame(self, text)
Write data to the websocket as a text frame
source code
 
close(self)
Close the websocket
source code
 
closed_handler(self, handler)
Set a closed handler on the connection, the handler receives a no parameters.
source code

Inherited from streams.ReadStream: data_handler, end_handler, exception_handler, pause, resume

Inherited from streams.ReadStream (private): _to_read_stream

Inherited from streams.WriteStream: drain_handler, set_write_queue_max_size, write_buffer, write_queue_full

Inherited from streams.WriteStream (private): _to_write_stream

Class Variables [hide private]

Inherited from streams.WriteStream: write_queue_max_size

Method Details [hide private]

__init__(self, websocket)
(Constructor)

source code 
Overrides: object.__init__
(inherited documentation)

write_binary_frame(self, buffer)

source code 

Write data to the websocket as a binary frame

Keyword arguments:

Parameters:
  • buffer - Buffer data to write to socket.

write_text_frame(self, text)

source code 

Write data to the websocket as a text frame

Keyword arguments:

Parameters:
  • text - text to write to socket

closed_handler(self, handler)

source code 

Set a closed handler on the connection, the handler receives a no parameters. This can be used as a decorator.

Keyword arguments: handler - The handler to be called when writing has been completed. It is wrapped in a ClosedHandler.