WebSocket script functions¶
Functions for C# (Cb.Call) and Python (cb.call). See Script functions for how to use them.
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 | What to put in |
|---|---|
data |
What to send, like "{\"alert\": \"raid\"}" or plain text. |
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.
var answer = await Cb.Call("websocket.broadcast", new { data = "{\"alert\": \"raid\"}", json = true });
answer = cb.call("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 | What to put in |
|---|---|
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.
var answer = await Cb.Call("websocket.clientConnect", new { connection = "My overlay" });
answer = cb.call("websocket.clientConnect", connection="My overlay")
websocket.clientDisconnect¶
Disconnects one of your WebSocket clients. Fails when no client matches.
| Value | What to put in |
|---|---|
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.
var answer = await Cb.Call("websocket.clientDisconnect", new { connection = "My overlay" });
answer = cb.call("websocket.clientDisconnect", connection="My overlay")
websocket.clientIndex¶
Finds the number of a WebSocket client in the list on the Servers page, by its name.
| Value | What to put in |
|---|---|
name |
The client's name, like "My overlay". |
Gives back: Its number (0 is the first), or -1 when no client has that name.
var answer = await Cb.Call("websocket.clientIndex", new { name = "My overlay" });
answer = cb.call("websocket.clientIndex", name="My overlay")
websocket.clientIsConnected¶
Checks whether one of your WebSocket clients is connected right now. Fails when no client matches.
| Value | What to put in |
|---|---|
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.
var answer = await Cb.Call("websocket.clientIsConnected", new { connection = "My overlay" });
answer = cb.call("websocket.clientIsConnected", connection="My overlay")
websocket.clientSend¶
Sends a message through one of your WebSocket clients. Fails when no client matches.
| Value | What to put in |
|---|---|
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 |
What to send, like "hello". |
Gives back: true when it was sent, false when the client is not connected.
var answer = await Cb.Call("websocket.clientSend", new { connection = "My overlay", data = "hello" });
answer = cb.call("websocket.clientSend", 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 | What to put in |
|---|---|
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 |
What to send, like "hello". |
sessionId |
Optional. Send only to this one connection (its session id). Leave it out for everyone. |
Gives back: How many connections got it.
var answer = await Cb.Call("websocket.serverBroadcast", new { connection = "Game server", data = "hello" });
answer = cb.call("websocket.serverBroadcast", connection="Game server", data="hello")
websocket.serverCloseAll¶
Disconnects every app connected to one of your custom WebSocket servers. The server keeps running.
| Value | What to put in |
|---|---|
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).
var answer = await Cb.Call("websocket.serverCloseAll", new { connection = "Game server" });
answer = cb.call("websocket.serverCloseAll", connection="Game server")
websocket.serverCloseSession¶
Disconnects one app from one of your custom WebSocket servers.
| Value | What to put in |
|---|---|
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 |
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.
var answer = await Cb.Call("websocket.serverCloseSession", new { connection = "Game server", sessionId = "3f2a9c" });
answer = cb.call("websocket.serverCloseSession", connection="Game server", sessionId="3f2a9c")
websocket.serverIndex¶
Finds the number of a custom WebSocket server in the list on the Servers page, by its name.
| Value | What to put in |
|---|---|
name |
The server's name, like "Game server". |
Gives back: Its number (0 is the first), or -1 when no server has that name.
var answer = await Cb.Call("websocket.serverIndex", new { name = "Game server" });
answer = cb.call("websocket.serverIndex", name="Game server")
websocket.serverIsListening¶
Checks whether one of your custom WebSocket servers is running.
| Value | What to put in |
|---|---|
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.
var answer = await Cb.Call("websocket.serverIsListening", new { connection = "Game server" });
answer = cb.call("websocket.serverIsListening", connection="Game server")
websocket.serverStart¶
Starts one of your custom WebSocket servers, so other apps can connect. Fails when no server matches.
| Value | What to put in |
|---|---|
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.
var answer = await Cb.Call("websocket.serverStart", new { connection = "Game server" });
answer = cb.call("websocket.serverStart", connection="Game server")
websocket.serverStop¶
Stops one of your custom WebSocket servers. Connected apps are disconnected.
| Value | What to put in |
|---|---|
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.
var answer = await Cb.Call("websocket.serverStop", new { connection = "Game server" });
answer = cb.call("websocket.serverStop", connection="Game server")