Skip to content

Reference Script Functions Websocket

Kristopher Barrantes edited this page Nov 5, 2026 · 2 revisions

WebSocket script functions

Also on the Cuebot Docs site.

Functions for C# (Cb.Call) and Python (a cb method each, or cb.call). See Script functions for how to use them.

A Run Python code step in the action editor

websocket.broadcast

Sends data to every app connected to Cuebot's WebSocket server, as a General.Custom event. Handy for your own overlays and tools.

Value In Python What to put in
data data What to send, like "{"alert": "raid"}" or plain text.
json json Optional. true reads data as JSON and sends it as an object (plain text if it is not valid JSON). Leave it out for false (send as text).

Gives back: How many apps got it.

C#

var answer = await Cb.Call("websocket.broadcast", new { data = "{\"alert\": \"raid\"}", json = true });

Python

answer = cb.websocket_broadcast(data="{\"alert\": \"raid\"}", json=True)

websocket.clientConnect

Connects one of your WebSocket clients (set up on the Servers page). Does nothing when it is already connected. Fails when no client matches.

Value In Python What to put in
connection connection Which WebSocket client from the Servers page: its number in the list (0 is the first), its name or its id. Leave it out for 0.

Gives back: Nothing.

C#

var answer = await Cb.Call("websocket.clientConnect", new { connection = "My overlay" });

Python

answer = cb.websocket_client_connect(connection="My overlay")

websocket.clientDisconnect

Disconnects one of your WebSocket clients. Fails when no client matches.

Value In Python What to put in
connection connection Which WebSocket client from the Servers page: its number in the list (0 is the first), its name or its id. Leave it out for 0.

Gives back: Nothing.

C#

var answer = await Cb.Call("websocket.clientDisconnect", new { connection = "My overlay" });

Python

answer = cb.websocket_client_disconnect(connection="My overlay")

websocket.clientIndex

Finds the number of a WebSocket client in the list on the Servers page, by its name.

Value In Python What to put in
name name The client's name, like "My overlay".

Gives back: Its number (0 is the first), or -1 when no client has that name.

C#

var answer = await Cb.Call("websocket.clientIndex", new { name = "My overlay" });

Python

answer = cb.websocket_client_index(name="My overlay")

websocket.clientIsConnected

Checks whether one of your WebSocket clients is connected right now. Fails when no client matches.

Value In Python What to put in
connection connection Which WebSocket client from the Servers page: its number in the list (0 is the first), its name or its id. Leave it out for 0.

Gives back: true when it is connected, otherwise false.

C#

var answer = await Cb.Call("websocket.clientIsConnected", new { connection = "My overlay" });

Python

answer = cb.websocket_client_is_connected(connection="My overlay")

websocket.clientSend

Sends a message through one of your WebSocket clients. Fails when no client matches.

Value In Python What to put in
connection connection Which WebSocket client from the Servers page: its number in the list (0 is the first), its name or its id. Leave it out for 0.
data data What to send, like "hello".

Gives back: true when it was sent, false when the client is not connected.

C#

var answer = await Cb.Call("websocket.clientSend", new { connection = "My overlay", data = "hello" });

Python

answer = cb.websocket_client_send(connection="My overlay", data="hello")

websocket.serverBroadcast

Sends a message to the apps connected to one of your custom WebSocket servers. Fails when the server is not running.

Value In Python What to put in
connection connection Which custom WebSocket server from the Servers page: its number in the list (0 is the first), its name or its id. Leave it out for 0.
data data What to send, like "hello".
sessionId session_id Optional. Send only to this one connection (its session id). Leave it out for everyone.

Gives back: How many connections got it.

C#

var answer = await Cb.Call("websocket.serverBroadcast", new { connection = "Game server", data = "hello" });

Python

answer = cb.websocket_server_broadcast(connection="Game server", data="hello")

websocket.serverCloseAll

Disconnects every app connected to one of your custom WebSocket servers. The server keeps running.

Value In Python What to put in
connection connection Which custom WebSocket server from the Servers page: its number in the list (0 is the first), its name or its id. Leave it out for 0.

Gives back: How many connections were closed (0 when the server is not running).

C#

var answer = await Cb.Call("websocket.serverCloseAll", new { connection = "Game server" });

Python

answer = cb.websocket_server_close_all(connection="Game server")

websocket.serverCloseSession

Disconnects one app from one of your custom WebSocket servers.

Value In Python What to put in
connection connection Which custom WebSocket server from the Servers page: its number in the list (0 is the first), its name or its id. Leave it out for 0.
sessionId session_id The session id of the connection to close, like the %sessionId% of a custom server trigger.

Gives back: true when it was closed, false when there is no such connection or the server is not running.

C#

var answer = await Cb.Call("websocket.serverCloseSession", new { connection = "Game server", sessionId = "3f2a9c" });

Python

answer = cb.websocket_server_close_session(connection="Game server", session_id="3f2a9c")

websocket.serverIndex

Finds the number of a custom WebSocket server in the list on the Servers page, by its name.

Value In Python What to put in
name name The server's name, like "Game server".

Gives back: Its number (0 is the first), or -1 when no server has that name.

C#

var answer = await Cb.Call("websocket.serverIndex", new { name = "Game server" });

Python

answer = cb.websocket_server_index(name="Game server")

websocket.serverIsListening

Checks whether one of your custom WebSocket servers is running.

Value In Python What to put in
connection connection Which custom WebSocket server from the Servers page: its number in the list (0 is the first), its name or its id. Leave it out for 0.

Gives back: true when it is running, otherwise false.

C#

var answer = await Cb.Call("websocket.serverIsListening", new { connection = "Game server" });

Python

answer = cb.websocket_server_is_listening(connection="Game server")

websocket.serverStart

Starts one of your custom WebSocket servers, so other apps can connect. Fails when no server matches.

Value In Python What to put in
connection connection Which custom WebSocket server from the Servers page: its number in the list (0 is the first), its name or its id. Leave it out for 0.

Gives back: Nothing.

C#

var answer = await Cb.Call("websocket.serverStart", new { connection = "Game server" });

Python

answer = cb.websocket_server_start(connection="Game server")

websocket.serverStop

Stops one of your custom WebSocket servers. Connected apps are disconnected.

Value In Python What to put in
connection connection Which custom WebSocket server from the Servers page: its number in the list (0 is the first), its name or its id. Leave it out for 0.

Gives back: Nothing.

C#

var answer = await Cb.Call("websocket.serverStop", new { connection = "Game server" });

Python

answer = cb.websocket_server_stop(connection="Game server")

Clone this wiki locally