Function quicksocket::try_send_messages[][src]

pub fn try_send_messages(
    py: Python<'_>,
    messages: Vec<MessagePayload>
) -> PyResult<()>

Send messages to all connected clients. The socket stream is flushed after buffering each message in the argument List, so it’s better to call this once per ‘update,’ rather than calling this method multiple times if multiple messages are all available to be sent.

The List may contain strings or bytes.

Will return false if there are not currently any active subscribers (websocket clients), indicating no data was sent. False may also be returned if there was an error trying to access the broadcast channel in the first place (i.e. thread contention to access it).

A return value of true does not guarantee all websocket clients received the message, as the tokio tasks for forwarding the messages to the clients must be able to receive the broadcast messages to forward them, which is subject to thread/task contention.