Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.websocket_api.http.WebSocketHandler Class Reference

Public Member Functions

None __init__ (self, HomeAssistant hass, web.Request request)
 
str __repr__ (self)
 
web.WebSocketResponse async_handle (self)
 
str description (self)
 

Private Member Functions

None _async_cleanup_writer_and_close (self, str|None disconnect_warn, ActiveConnection|None connection)
 
ActiveConnection _async_handle_auth_phase (self, AuthPhase auth, Callable[[bytes], Coroutine[Any, Any, None]] send_bytes_text)
 
None _async_handle_hass_stop (self, Event event)
 
None _async_increase_writer_limit (self, WebSocketWriter writer)
 
None _async_websocket_command_phase (self, ActiveConnection connection)
 
None _cancel (self)
 
None _cancel_peak_checker (self)
 
None _check_write_peak (self, dt.datetime _utc_time)
 
None _release_ready_future_or_reschedule (self)
 
None _send_message (self, str|bytes|dict[str, Any] message)
 
None _writer (self, ActiveConnection connection, Callable[[bytes], Coroutine[Any, Any, None]] send_bytes_text)
 

Private Attributes

 _authenticated
 
 _closing
 
 _connection
 
 _handle_task
 
 _hass
 
 _logger
 
 _loop
 
 _message_queue
 
 _peak_checker_unsub
 
 _ready_future
 
 _release_ready_queue_size
 
 _request
 
 _writer_task
 
 _wsock
 

Static Private Attributes

tuple __slots__
 

Detailed Description

Handle an active websocket client connection.

Definition at line 69 of file http.py.

Constructor & Destructor Documentation

◆ __init__()

None homeassistant.components.websocket_api.http.WebSocketHandler.__init__ (   self,
HomeAssistant  hass,
web.Request  request 
)
Initialize an active connection.

Definition at line 89 of file http.py.

Member Function Documentation

◆ __repr__()

str homeassistant.components.websocket_api.http.WebSocketHandler.__repr__ (   self)
Return the representation.

Definition at line 111 of file http.py.

◆ _async_cleanup_writer_and_close()

None homeassistant.components.websocket_api.http.WebSocketHandler._async_cleanup_writer_and_close (   self,
str | None  disconnect_warn,
ActiveConnection | None   connection 
)
private
Cleanup the writer and close the websocket.

Definition at line 500 of file http.py.

◆ _async_handle_auth_phase()

ActiveConnection homeassistant.components.websocket_api.http.WebSocketHandler._async_handle_auth_phase (   self,
AuthPhase  auth,
Callable[[bytes], Coroutine[Any, Any, None]]  send_bytes_text 
)
private
Handle the auth phase of the websocket connection.

Definition at line 372 of file http.py.

◆ _async_handle_hass_stop()

None homeassistant.components.websocket_api.http.WebSocketHandler._async_handle_hass_stop (   self,
Event  event 
)
private
Cancel this connection.

Definition at line 297 of file http.py.

◆ _async_increase_writer_limit()

None homeassistant.components.websocket_api.http.WebSocketHandler._async_increase_writer_limit (   self,
WebSocketWriter  writer 
)
private

Definition at line 414 of file http.py.

◆ _async_websocket_command_phase()

None homeassistant.components.websocket_api.http.WebSocketHandler._async_websocket_command_phase (   self,
ActiveConnection   connection 
)
private
Handle the command phase of the websocket connection.

Definition at line 452 of file http.py.

◆ _cancel()

None homeassistant.components.websocket_api.http.WebSocketHandler._cancel (   self)
private
Cancel the connection.

Definition at line 287 of file http.py.

◆ _cancel_peak_checker()

None homeassistant.components.websocket_api.http.WebSocketHandler._cancel_peak_checker (   self)
private
Cancel the peak checker.

Definition at line 181 of file http.py.

◆ _check_write_peak()

None homeassistant.components.websocket_api.http.WebSocketHandler._check_write_peak (   self,
dt.datetime  _utc_time 
)
private
Check that we are no longer above the write peak.

Definition at line 266 of file http.py.

◆ _release_ready_future_or_reschedule()

None homeassistant.components.websocket_api.http.WebSocketHandler._release_ready_future_or_reschedule (   self)
private
Release the ready future or reschedule.

We will release the ready future if the queue did not grow since the
last time we tried to release the ready future.

If we reach PENDING_MSG_MAX_FORCE_READY, we will release the ready future
immediately so avoid the coalesced messages from growing too large.

Definition at line 240 of file http.py.

◆ _send_message()

None homeassistant.components.websocket_api.http.WebSocketHandler._send_message (   self,
str | bytes | dict[str, Any]  message 
)
private
Queue sending a message to the client.

Closes connection if the client is not reading the messages.

Async friendly.

Definition at line 188 of file http.py.

◆ _writer()

None homeassistant.components.websocket_api.http.WebSocketHandler._writer (   self,
ActiveConnection  connection,
Callable[[bytes], Coroutine[Any, Any, None]]  send_bytes_text 
)
private
Write outgoing messages.

Definition at line 129 of file http.py.

◆ async_handle()

web.WebSocketResponse homeassistant.components.websocket_api.http.WebSocketHandler.async_handle (   self)
Handle a websocket response.

Definition at line 301 of file http.py.

◆ description()

str homeassistant.components.websocket_api.http.WebSocketHandler.description (   self)
Return a description of the connection.

Definition at line 121 of file http.py.

Member Data Documentation

◆ __slots__

tuple homeassistant.components.websocket_api.http.WebSocketHandler.__slots__
staticprivate
Initial value:
= (
"_hass",
"_loop",
"_request",
"_wsock",
"_handle_task",
"_writer_task",
"_closing",
"_authenticated",
"_logger",
"_peak_checker_unsub",
"_connection",
"_message_queue",
"_ready_future",
"_release_ready_queue_size",
)

Definition at line 72 of file http.py.

◆ _authenticated

homeassistant.components.websocket_api.http.WebSocketHandler._authenticated
private

Definition at line 410 of file http.py.

◆ _closing

homeassistant.components.websocket_api.http.WebSocketHandler._closing
private

Definition at line 289 of file http.py.

◆ _connection

homeassistant.components.websocket_api.http.WebSocketHandler._connection
private

Definition at line 405 of file http.py.

◆ _handle_task

homeassistant.components.websocket_api.http.WebSocketHandler._handle_task
private

Definition at line 323 of file http.py.

◆ _hass

homeassistant.components.websocket_api.http.WebSocketHandler._hass
private

Definition at line 91 of file http.py.

◆ _logger

homeassistant.components.websocket_api.http.WebSocketHandler._logger
private

Definition at line 99 of file http.py.

◆ _loop

homeassistant.components.websocket_api.http.WebSocketHandler._loop
private

Definition at line 92 of file http.py.

◆ _message_queue

homeassistant.components.websocket_api.http.WebSocketHandler._message_queue
private

Definition at line 536 of file http.py.

◆ _peak_checker_unsub

homeassistant.components.websocket_api.http.WebSocketHandler._peak_checker_unsub
private

Definition at line 185 of file http.py.

◆ _ready_future

homeassistant.components.websocket_api.http.WebSocketHandler._ready_future
private

Definition at line 148 of file http.py.

◆ _release_ready_queue_size

homeassistant.components.websocket_api.http.WebSocketHandler._release_ready_queue_size
private

Definition at line 222 of file http.py.

◆ _request

homeassistant.components.websocket_api.http.WebSocketHandler._request
private

Definition at line 533 of file http.py.

◆ _writer_task

homeassistant.components.websocket_api.http.WebSocketHandler._writer_task
private

Definition at line 406 of file http.py.

◆ _wsock

homeassistant.components.websocket_api.http.WebSocketHandler._wsock
private

Definition at line 94 of file http.py.


The documentation for this class was generated from the following file: