mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Fix documentation of cloud io device.
This commit is contained in:
parent
96c010b441
commit
991d7be7f4
1 changed files with 43 additions and 12 deletions
|
@ -1,32 +1,63 @@
|
||||||
|
const Variable = require('../engine/variable');
|
||||||
|
const log = require('../util/log');
|
||||||
|
|
||||||
|
class Cloud {
|
||||||
|
/**
|
||||||
|
* @typedef updateVariable
|
||||||
|
* @param {string} name The name of the cloud variable to update on the server
|
||||||
|
* @param {(string | number)} value The value to update the cloud variable with.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A cloud data provider, responsible for managing the connection to the
|
||||||
|
* cloud data server and for posting data about cloud data activity to
|
||||||
|
* this IO device.
|
||||||
|
* @typedef {object} CloudProvider
|
||||||
|
* @property {updateVariable} updateVariable A function which sends a cloud variable
|
||||||
|
* update to the cloud data server.
|
||||||
|
* @property {Function} requestCloseConnection A function which closes
|
||||||
|
* the connection to the cloud data server.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Part of a cloud io data post indicating a cloud variable update.
|
||||||
|
* @typedef {object} VarUpdateData
|
||||||
|
* @property {string} name The name of the variable to update
|
||||||
|
* @property {(number | string)} value The scalar value to update the variable with
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A cloud io data post message.
|
||||||
|
* @typedef {object} CloudIOData
|
||||||
|
* @property {VarUpdateData} varUpdate A {@link VarUpdateData} message indicating
|
||||||
|
* a cloud variable update
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cloud IO Device responsible for sending and receiving messages from
|
* Cloud IO Device responsible for sending and receiving messages from
|
||||||
* cloud provider (mananging the cloud server connection) and interacting
|
* cloud provider (mananging the cloud server connection) and interacting
|
||||||
* with cloud variables in the current project.
|
* with cloud variables in the current project.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const Variable = require('../engine/variable');
|
|
||||||
const log = require('../util/log');
|
|
||||||
|
|
||||||
class Cloud {
|
|
||||||
constructor () {
|
constructor () {
|
||||||
/**
|
/**
|
||||||
* Reference to the cloud data provider, responsible for mananging
|
* Reference to the cloud data provider, responsible for mananging
|
||||||
* the web socket connection to the cloud data server.
|
* the web socket connection to the cloud data server.
|
||||||
* @type{!object}
|
* @type {?CloudProvider}
|
||||||
*/
|
*/
|
||||||
this.provider = null;
|
this.provider = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference to the stage target which owns the cloud variables
|
* Reference to the stage target which owns the cloud variables
|
||||||
* in the project.
|
* in the project.
|
||||||
* @type{!Target}
|
* @type {?Target}
|
||||||
*/
|
*/
|
||||||
this.stage = null;
|
this.stage = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a reference to the cloud data provider.
|
* Set a reference to the cloud data provider.
|
||||||
* @param {object} provider The cloud data provider
|
* @param {CloudProvider} provider The cloud data provider
|
||||||
*/
|
*/
|
||||||
setProvider (provider) {
|
setProvider (provider) {
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
|
@ -43,7 +74,7 @@ class Cloud {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle incoming data to this io device.
|
* Handle incoming data to this io device.
|
||||||
* @param {object} data The data to process
|
* @param {CloudIOData} data The {@link CloudIOData} object to process
|
||||||
*/
|
*/
|
||||||
postData (data) {
|
postData (data) {
|
||||||
if (data.varUpdate) {
|
if (data.varUpdate) {
|
||||||
|
@ -66,8 +97,8 @@ class Cloud {
|
||||||
/**
|
/**
|
||||||
* Update a cloud variable in the runtime based on the message received
|
* Update a cloud variable in the runtime based on the message received
|
||||||
* from the cloud provider.
|
* from the cloud provider.
|
||||||
* @param {object} varUpdate Data describing a cloud variable update received
|
* @param {VarUpdateData} varUpdate A {@link VarUpdateData} object describing
|
||||||
* from the cloud data provider.
|
* a cloud variable update received from the cloud data provider.
|
||||||
*/
|
*/
|
||||||
updateCloudVariable (varUpdate) {
|
updateCloudVariable (varUpdate) {
|
||||||
const varName = varUpdate.name;
|
const varName = varUpdate.name;
|
||||||
|
|
Loading…
Reference in a new issue