circuits.web.dispatchers.websockets – WebSockets — circuits 2.1.0 documentation

# circuits 2.1.0 documentation

# `circuits.web.dispatchers.websockets` – WebSockets

## Events

## Components

class `circuits.web.dispatchers.websockets.` `WebSockets`(path=None, wschannel='ws', *args, **kwargs)

  Bases: `circuits.core.components.BaseComponent`

  This class implements an RFC 6455 compliant WebSockets dispatcher that handles the WebSockets handshake and upgrades the connection.

  The dispatcher listens on its channel for `Request` events and tries to match them with a given path. Upon a match, the request is checked for the proper Opening Handshake information. If successful, the dispatcher confirms the establishment of the connection to the client. Any subsequent data from the client is handled as a WebSocket data frame, decoded and fired as a `Read` event on the `wschannel` passed to the constructor. The data from `Write` events on that channel is encoded as data frames and forwarded to the client.

  Firing a `Close` event on the `wschannel` closes the connection in an orderly fashion (i.e. as specified by the WebSocket protocol).

  Parameters: | path – the path to handle. Requests that start with this path are considered to be WebSocket Opening Handshakes. wschannel – the channel on which `Read` events from the client will be delivered and where `Write` events to the client will be sent to.

## Functions

none