Description

Settings for saving values in a MultiplayerSession.

Example

var options = StorageOptions.create();
options.scope = StorageScope.Session;

// Get a persisted value stored with specified scope
function setStoredValue(key, value, op) {
script.session.setStoredValue(key, value, op,
function onSuccess() {
screenLog("Value [" + key + "] was persisted in scope! " + op.scope);
},
function handleError(code, description) {
screenLog("Error code: " + code + " description: " + description);
});

}

// Get value stored with specified scope
function getStoredValue(key, scope) {
script.session.getStoredValue(key, scope,
function onSuccess(key, value) {
screenLog("Value of " + key + " is: " + value);
},
function handleError(code, description) {
screenLog("Error code: " + code + " description: " + description);
});
}

// Delete value stored with specified scope
function deleteStoredValue(key, scope) {
// Delete a persisted value from the collection
script.session.deleteStoredValue(key, scope,
function onSuccess() {
screenLog("Value " + key + " was deleted");
},
function handleError(code, description) {
screenLog("Error code: " + code + " description: " + description);
});
}

function listStoredValues(scope) {
var pageNumber = 0;
var limit = 10; //constant

function handleError(code, description) {
screenLog("Error code: " + code + " description: " + description);
};
function onListRetrieved(results, cursor) {
screenLog(" page " + (pageNumber++) + " contains " + results.length + " results " + "cursor " + cursor);

// Results are returned as a list of [key, value] tuples
for (var i = 0; i < results.length; ++i) {
const key = results[i][0];
const value = results[i][1];
screenLog(" - key: " + key + " value: " + value);
}

// Request the next page of results
if (results.length == limit) {
script.session.listStoredValues(options.scope, cursor, onListRetrieved, handleError);
}
}
script.session.listStoredValues(scope, "", onListRetrieved, handleError);
}
interface StorageOptions {
    scope: StorageScope;
    getTypeName(): string;
    isOfType(type): boolean;
    isSame(other): boolean;
}

Hierarchy (view full)

Properties

Methods

Properties

Description

The Storage Scope to set, get, or delete values from.

Methods

  • Returns string

    Description

    Returns the name of this object's type.

  • Parameters

    • type: string

    Returns boolean

    Description

    Returns true if the object matches or derives from the passed in type.

  • Parameters

    Returns boolean

    Description

    Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Generated using TypeDoc