CreatorCreator
Home
Getting Started
  • 中文简体
  • English
Home
Getting Started
  • 中文简体
  • English
  • Creator

    • Getting Started
  • Stream Dock

    • Plugin SDK
    • Icon Pack

      • Overview
      • Terminology
      • Creating an Icon Pack
      • Icon Specifications
    • Scene Configuration

      • What is a Scenario Configuration?
      • Exporting
      • Use Cases
  • mPanel

    • Plugin SDK
  • Linux StreamDock SDK

    • Cpp SDK

      • Overview
      • Dependency
      • Device Manager
      • StreamDock Base Class
      • StreamDock293
      • Communication transmission
      • Example
      • Source code
    • Python SDK

      • Overview
      • Dependency
      • DeviceManager
      • StreamDock Base Class
      • StreamDock293
      • Example
      • Source Code
  • Windows StreamDock SDK

    • WebSocket SDK

      • Overview
      • Getting Started
      • Events to Send
      • Received Events
    • Cpp SDK

      • Overview
      • Dependency
      • Device manager
      • StreamDock Base Class
      • StreamDock293
      • Transport
      • Example
      • Source Code
  • Support

    • Help and Bug Reporting

Events to Send

You can send the following events to the SDK via WebSocket:

EventDescription
getFirmVersionRetrieve the firmware version
readRead event (key event, knob event, background image setting success event, all events will be sent before reading begins. It only needs to be sent once after connection)
setBackgroundImgSet the background image (different devices may have different background images)
setBackgroundImgDataSet the background image using byte data (different devices may have different background images)
clearAllIconClear all button icons (recommended to send this event before setting icons to clear the background image)
clearIconClear a specific button icon
setKeyImgSet an icon for a specific button (icon size may vary by device)
setKeyImgDataSet an icon for a specific button using byte data (icon size may vary by device)
setBrightnessSet the device brightness (0-100)
refreshRefresh the device (icons will display after refresh; the SDK already calls this by default)

getFirmVersion

Retrieve the firmware version (in base64 format)

{
    "event": "getFirmVersion",
    "path": path
}
MemberDescription
eventgetFirmVersion
pathDevice path (unique ID)

read

Read events (key events and knob events will only start reading after this event is sent). It is recommended to send this event directly after the websocket is connected to start event monitoring. When the device is disconnected, it will automatically stop monitoring.

{
    "event":"read",
    "path":path
} 
MemberDescription
eventread
pathDevice path (unique identifier, device connection event acquisition)

setBackgroundImg

Set the background image (the background image may be different for different devices). During the process of setting the background image, no other events can be sent, otherwise the screen may be distorted. You need to receive the background image setting success event before sending other events (the background image setting success event needs to be sent after the read event is sent, so the read event needs to be sent before setBackgroundImg)

{
    "event":"setBackgroundImg",
    "path":path,
    "payload":{
        "url":"E:\\img\\bg.jpg"
    }
} 
MemberDescription
eventsetBackgroundImg
pathDevice path (unique identifier, device connection event acquisition)
payloadJSON object

The payload object contains the following members:

payloadDescription
urlThe address of the background image to be set (293V2\293V3\N4 background image size: 800×480, N3 background image size: 320×240)

setBackgroundImgData

Set the background image through byte data (the background image may be different for different devices). Do not send other events during the background image setting process, otherwise the screen may be distorted. You need to receive the background image setting success event before sending other events (the background image setting success event needs to be sent after the read event is sent, so the read event needs to be sent before setBackgroundImgData)

{
    "event":"setBackgroundImgData",
    "path":path,
    "payload":{
        "imgData":base64String
    }
} 
MemberDescription
eventsetBackgroundImgData
pathDevice path (unique identifier, device connection event acquisition)
payloadJSON object

The payload object contains the following members:

payloadDescription
imgDataRGB byte array in bsae64 format to be set (293V2\293V3\N4 background image size: 800×480, N3 background image size: 320×240)

Example:

const canvas = document.createElement("canvas");
const ctx = canvas.getContext("2d");
canvas.width = 800
canvas.height = 480

ctx.fillStyle = "pink";
ctx.fillRect(0, 0, 800, 480);
ctx.font = `${100}px'YaHei'`;
ctx.fillStyle = "white";
ctx.fillText("TEST", 150, 100);

const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
const byteArray = imageData.data; // Get byte array

// Convert RGBA to RGB (RGB channels are used in SDK)
const rgbByteArray = [];
for (let i = 0; i < byteArray.length; i += 4) {
    rgbByteArray.push(byteArray[i+2], byteArray[i+1], byteArray[i]);
}

// Convert RGB byte array to Base64
function byteArrayToBase64(byteArray) {
    let binary = '';
    for (let i = 0; i < byteArray.length; i++) {
        binary += String.fromCharCode(byteArray[i]);
    }
    return btoa(binary); // Convert a binary string to Base64
}

const base64String = byteArrayToBase64(rgbByteArray);
const data = {
    "event": "setBackgroundImgData",
    "path": path,
    "payload": {
        "imgData": base64String,
    }
};
ws.send(JSON.stringify(data));

clearAllIcon

Clear all button icons (it is recommended to send this event to clear the background image before setting the icon)

{
    "event":"clearAllIcon",
    "path":path
} 
MemberDescription
eventclearAllIcon
pathDevice path (unique identifier, device connection event acquisition)

clearIcon

Clear a button icon

{
    "event":"clearIcon",
    "path":path,
    "payload":{
        "key":1
    }
} 
MemberDescription
eventclearIcon
pathDevice path (unique identifier, device connection event acquisition)
payloadJSON object

The payload object contains the following members:

payloadDescription
keyKey number starts from 1

setKeyImg

Set a key icon (different device icon sizes are different)

{
    "event":"setKeyImg",
    "path":path,
    "payload":{
        "url":"E:\\img\\icon.jpg",
        "key":1,
        "refresh":false
    }
} 
MemberDescription
eventsetKeyImg
pathDevice path (unique identifier, device connection event acquisition)
payloadjson object

The payload object contains the following members:

payloadDescription
urlAddress of the key icon to be set
keyThe key sequence to be set starts from 1
refreshWhether to refresh the display, optional parameter, refresh the display by default, if set to false, you need to call the refresh event to refresh the display (mainly used to batch set pictures to refresh all displays at once)

TIP

293V2 image size: 100×100

293V3 image size: 112×112

N3 image size: 64×64

N4 image size: 112×112 (key), 176×112 (secondary screen)

setKeyImgData

Set a key icon through byte data (icon sizes are different for different devices)

{
    "event":"setKeyImgData",
    "path":path,
    "payload":{
        "imgData":base64String,
        "key":1,
        "refresh":false
    }
} 
MemberDescription
eventsetKeyImgData
pathDevice path (unique identifier, device connection event acquisition)
payloadJSON object

The payload object contains the following members:

payloadDescription
imgDataRGB byte array in bsae64 format of the key icon to be set
keyThe key sequence to be set starts from 1
refreshWhether to refresh the display, optional parameter, refresh the display by default, if set to false, you need to call the refresh event to refresh the display (mainly used to batch set pictures to refresh all displays at once)

TIP

293V2 image size: 100×100

293V3 image size: 112×112

N3 image size: 64×64

N4 image size: 112×112 (key), 176×112 (secondary screen)

Example:

const canvas = document.createElement("canvas");
const ctx = canvas.getContext("2d");
canvas.width = canvas.height = 100;

ctx.fillStyle = "black";
ctx.fillRect(0, 0, 100, 100);

ctx.font = `${35}px'YaHei'`;
ctx.fillStyle = "white";
ctx.fillText("tExt", 0, 50);

const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
const byteArray = imageData.data; // Get byte array

// Convert RGBA to RGB (RGB channels are used in SDK)
const rgbByteArray = [];
for (let i = 0; i < byteArray.length; i += 4) {
    rgbByteArray.push(byteArray[i+2], byteArray[i+1], byteArray[i]);
}

// Convert RGB byte array to Base64
function byteArrayToBase64(byteArray) {
    let binary = '';
    for (let i = 0; i < byteArray.length; i++) {
        binary += String.fromCharCode(byteArray[i]);
    }
    return btoa(binary); // Convert a binary string to Base64
}

const base64String = byteArrayToBase64(rgbByteArray);
const data = {
    "event": "setKeyImgData",
    "path": path,
    "payload": {
        "imgData": base64String,
        "key": 15
    }
};
ws.send(JSON.stringify(data))

setBrightness

Set device brightness (0-100)

{
    "event":"setBrightness",
    "path":path,
    "payload":{
        "brightness":100
    }
} 
MemberDescription
eventsetBrightness
pathDevice path (unique identifier, device connection event acquisition)
payloadJSON object

The payload object contains the following members:

payloadDescription
brightnessBrightness (0-100)

refresh

Refresh the device (refresh after setting the icon, it has been called by default in the SDK)

{
    "event":"refresh",
    "path":path
} 
MemberDescription
eventrefresh
pathDevice path (unique identifier, device connection event acquisition)
Last Updated:
Contributors: Heart
Prev
Getting Started
Next
Received Events