Exemple #1
0
def print_event(event: Event) -> None:
    """
    Used from main script to print event as JSON.
    """

    print(event.to_json())
    sys.stdout.flush()
Exemple #2
0
async def broadcast_event(event: events.Event) -> None:

    logger.debug(event)

    if glob.USERS.interfaces:
        message = event.to_json()
        await asyncio.gather(*[ws_server.send_json_to_client(intf, message) for intf in glob.USERS.interfaces])
Exemple #3
0
async def broadcast_event(
        event: events.Event,
        exclude_ui: Optional[WebSocketServerProtocol] = None) -> None:

    if (exclude_ui is None
            and glob.INTERFACES) or (exclude_ui and len(glob.INTERFACES) > 1):
        message = event.to_json()
        await asyncio.gather(*[
            ws_server.send_json_to_client(intf, message)
            for intf in glob.INTERFACES if intf != exclude_ui
        ])
Exemple #4
0
async def event(interface: WebSocketServerProtocol,
                event: events.Event) -> None:
    await ws_server.send_json_to_client(interface, event.to_json())
Exemple #5
0
async def send_to_clients(event: Event) -> None:

    if CLIENTS:
        data = event.to_json()
        await asyncio.wait([client.send(data) for client in CLIENTS])