You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes when trying to connect to the cloud like this:
Client.login().then(()=>{letcloud=Client.session.createCloudSession(548738926);cloud.connect().then(()=>{console.log("Successfully connected to cloud!");cloud.on("set",variable=>{console.log("Cloud variable",variable.name,"set to",variable.value);});});});
The following error appears:
undefined:2
{"method":"set","project_id":"548862682","name":"☁ CloudService response","value":"2410100100050202100307010909100703003819142363351915632419173523"}
^
SyntaxError: Unexpected token { in JSON at position 86
at JSON.parse (<anonymous>)
at WebSocket.<anonymous> (/home/runner/dictionary/node_modules/node-scratch-client/src/Struct/CloudSession.js:87:25)
at WebSocket.emit (events.js:314:20)
at WebSocket.EventEmitter.emit (domain.js:483:12)
at Receiver.receiverOnMessage (/home/runner/dictionary/node_modules/node-scratch-client/node_modules/ws/lib/websocket.js:789:20)
at Receiver.emit (events.js:314:20)
at Receiver.EventEmitter.emit (domain.js:483:12)
at Receiver.dataMessage (/home/runner/dictionary/node_modules/node-scratch-client/node_modules/ws/lib/receiver.js:422:14)
at /home/runner/dictionary/node_modules/node-scratch-client/node_modules/ws/lib/receiver.js:379:23
at /home/runner/dictionary/node_modules/node-scratch-client/node_modules/ws/lib/permessage-deflate.js:298:9
This is because sometimes the API sends multiple objects at once in a single string, like so:
The way to solve this is simple. Separate the string by line to make an array of chunks, and run the code for every one of them, replacing the function on line 85 in src/Struct/CloudSession.js with this:
connection.on("message",function(chunks){letchunksArr=chunks.split("\n");for(leti=0;i<chunksArr.length;i++){letchunk=chunksArr[i];if(!chunk){continue;}letjson=JSON.parse(chunk);_this._client._debugLog("CloudData: Received message: "+json);if(json.method==="set"){_this._variables[json.name]=newCloudVariable(_this._client,{name: json.name,value: json.value});_this.emit("set",_this._variables[json.name]);}else{_this._client._debugLog("CloudData: Method not supported: "+json.method);}}});
The text was updated successfully, but these errors were encountered:
Sometimes when trying to connect to the cloud like this:
The following error appears:
This is because sometimes the API sends multiple objects at once in a single string, like so:
The way to solve this is simple. Separate the string by line to make an array of chunks, and run the code for every one of them, replacing the function on line 85 in
src/Struct/CloudSession.js
with this:The text was updated successfully, but these errors were encountered: