circuits.web.websocket – WebSocket Client — circuits 2.1.0 documentation

# circuits 2.1.0 documentation

# `circuits.web.websocket` – WebSocket Client

## Events

## Components

class `circuits.web.websocket.` `WebSocketClient`(url, channel='wsclient', wschannel='ws', headers={})

  Bases: `circuits.core.components.BaseComponent`

  An RFC 6455 compliant WebSocket client component. Upon receiving a `circuits.web.client.Connect` event, the component tries to establish the connection to the server in a two stage process. First, a `circuits.net.sockets.Connect` event is sent to a child `TCPClient`. When the TCP connection has been established, the HTTP request for opening the WebSocket is sent to the server. A failure in this setup process is signaled by a `NotConnected` event.

  When the server accepts the request, the WebSocket connection is established and can be used very much like an ordinary socket by handling `Read` events on and sending `Write` events to the channel specified as the `wschannel` parameter of the constructor. Firing a `Close` event on that channel closes the connection in an orderly fashion (i.e. as specified by the WebSocket protocol).

  Parameters: | url – the URL to connect to. channel – the channel used by this component wschannel – the channel used for the actual WebSocket communication (read, write, close events) headers – additional headers to be passed with the WebSocket setup HTTP request

  `channel` = 'wsclient'
  `close`()
  `connected`

## Functions