Repository navigation
Reference Script Functions Websocket
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.
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)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")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")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")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")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")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")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")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")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")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")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")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")Cuebot by Tech Daddy Digital · MIT license · Privacy
Cuebot Docs (the same pages, nicer to read)
- Home
- Start here
-
Guides
- Chat commands
- Overlays and alerts
- Writing your own overlay widgets
- Text-to-speech
- Music and now playing
- Points, store and giveaways
- Subathons and goals
- Stream apps and devices
- VTuber apps
- Stream Deck
- The phone app
- Donations and integrations
- Discord bot
- The setup assistant and AI tools
- The assistant on your own computer
- Moving from Streamer.bot
- Cuebot's servers
- Writing code (C# and Python)
- Python in detail
- Using your own code editor
- Controlling Cuebot from other programs
- Backups and your data
- Linux
- Command-line options
- Troubleshooting
- What's experimental
- Reference
