Document toolboxDocument toolbox

Custom packages for the CeeCloudServer (RemoteModel)

This page shows you how to use custom commands to communicate between the web client and the CeeCloudServer using the already established WebSocket.

Client

Add this code in the client (this.m_socket is the web socket which you pass to the constructor of cee.ug.RemoteModel):

    this.m_socket.on("CustomDataResponse", (data:any) => {         console.log(`Response from client: ${JSON.stringify(data, null, 2)}`)     });     this.m_socket.emit("GetCustomData", {command: "getInfo", data: "partId:123"});

 Server

In the CeeCloudServer, add this to the main.js file, before the serverInstance.start(); line:

serverInstance.addCustomPacketHandler("GetCustomData", (packetData, callback) => {     console.log(`packetData: incomingPacketName:${packetData.incomingPacketName}, incomingData: ${JSON.stringify(packetData.incomingData, null, 2)},               modelKey: ${packetData.modelKey}, fullModelFileName: ${packetData.fullModelFileName}`);     const customData = { myValue: 123, myString: "ABC" };     callback("CustomDataResponse", customData); });

Running the example 

Executing the code above in the client gives the following output:

Client side

Response from client: { "myValue": 123,  "myString": "ABC" }

Server side