Python - websocket.send()

Send a message to a connected websocket client.

from nitric.resources import websocket
from nitric.application import Nitric
public_websocket = websocket("public")
async def send_hello_message(connection_id: string):
await public_websocket.send(connection_id, b"Hello")
Nitric.run()

Parameters

  • Name
    connection_id
    Required
    Required
    Type
    string
    Description

    The ID of the connection to send the message to on this websocket.

  • Name
    data
    Required
    Required
    Type
    bytes
    Description

    The byte data to send to that connection

Do not send messages to a connection during it's connect callback, if you need to acknowledge connection, do so by using a topic

Last updated on Oct 16, 2024