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.""" """Dispatch an event to a list of states."""
res = [] res = []
event, data = event_data
for state in states: for state in states:
try: try:
event, data = event_data if state.ws:
await state.ws.dispatch(event, data) await state.ws.dispatch(event, data)
res.append(state.session_id) res.append(state.session_id)
except Exception: except Exception:
log.exception("error while dispatching") log.exception("error while dispatching")