only dispatch to states with websockets

This commit is contained in:
Luna 2020-06-26 22:21:26 -03:00
parent de8954066a
commit 64498ba3f2
1 changed files with 4 additions and 3 deletions

View File

@ -30,11 +30,12 @@ async def send_event_to_states(
"""Dispatch an event to a list of states."""
res = []
event, data = event_data
for state in states:
try:
event, data = event_data
await state.ws.dispatch(event, data)
res.append(state.session_id)
if state.ws:
await state.ws.dispatch(event, data)
res.append(state.session_id)
except Exception:
log.exception("error while dispatching")