circuits.web.websockets.client module¶
- class circuits.web.websockets.client.WebSocketClient(*args, **kwargs)¶
Bases:
BaseComponentAn RFC 6455 compliant WebSocket client component. Upon receiving a
circuits.web.client.Connectevent, the component tries to establish the connection to the server in a two stage process. First, acircuits.net.events.connectevent is sent to a childTCPClient. 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 raising anNotConnectedexception.When the server accepts the request, the WebSocket connection is established and can be used very much like an ordinary socket by handling
readevents on and sendingwriteevents to the channel specified as thewschannelparameter of the constructor. Firing acloseevent 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()¶
- property connected¶