Serialize websocket event message once (#40453)
Since most of the json serialize work for the websocket was done multiple times for the same message, we can avoid the overhead of serializing the same message many times (once per websocket client) with a cache.
This commit is contained in:
parent
d82b97fbe1
commit
f0f817c361
5 changed files with 120 additions and 32 deletions
|
@ -77,7 +77,7 @@ def handle_subscribe_events(hass, connection, msg):
|
|||
):
|
||||
return
|
||||
|
||||
connection.send_message(messages.event_message(msg["id"], event))
|
||||
connection.send_message(messages.cached_event_message(msg["id"], event))
|
||||
|
||||
else:
|
||||
|
||||
|
@ -87,7 +87,7 @@ def handle_subscribe_events(hass, connection, msg):
|
|||
if event.event_type == EVENT_TIME_CHANGED:
|
||||
return
|
||||
|
||||
connection.send_message(messages.event_message(msg["id"], event.as_dict()))
|
||||
connection.send_message(messages.cached_event_message(msg["id"], event))
|
||||
|
||||
connection.subscriptions[msg["id"]] = hass.bus.async_listen(
|
||||
event_type, forward_events
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue