SDK functions that access Muxy Twitch Extension state and configuration data.

Updating State and Configuration Values

All state and configuration options are stored as key-value pairs in a JSON object. Values can be updated using a specified JSON patch operation. Supported operations are “add”, “remove”, “replace”, “move”, “copy”, “test”. The operations are applied to the current state value in order: if any of them fails. the entire operation fails. The "test" operation succeeds if the given value is present, and fails if it is not.

You can perform an update operation on the entire JSON object, or on a given key. Specific value updates have separate functions for each data type. For these functions, you provide a path within the JSON object to the desired key. For example, suppose you want to replace values in the following JSON object:

{
  "name": "Judy",
  "health": "30"
  "details" : ["val1", "val2", "val3"]
}

Use calls like this, referencing keys at the top level of the object:

// replace a string value
UpdateStateWithString(STATE_TARGET_EXTENSION, "replace", "/name", "Judy B");
// replace an integer value
UpdateStateWithInteger(STATE_TARGET_EXTENSION, "replace", "/health", 100);
// replace an array value using zero-based index
UpdateStateWithString(STATE_TARGET_EXTENSION, "replace", "/details/0", "first-value");

Extension and Channel State Handling

Muxy stores extension state on a per-extension or per-channel basis. A state value is a JSON object. Each call takes the target state store to be updated and the patch operation to be performed, as well as the new value.

  • The target state store is one of: STATE_TARGET_CHANNEL, STATE_TARGET_EXTENSION
  • The update operation is one of: “add”, “remove”, “replace”, “move”, “copy”, “test”.

There are separate calls for storing state values of specific data types. These take the path to a key within the current JSON object, and a new value of the given type for that key.

Get and update calls are asynchronous. You must supply a callback to handle the response when the operation has completed.

You can subscribe to and unsubscribe from events for specific state targets; see Event Handling.

FunctionDescriptionC# Signature
SetStateSet Target state to new JSON value.UInt16 SetState
(string Target, string Json)
GetStateRetrieve the value of Target state and pass it to the callback.UInt16 GetState
(string Target,
GetStateCallback Callback)
GetStateCallbackHandler signature for response to GetState() call.delegate void GetStateCallback
(StateUpdate Response)
UpdateStateCallbackHandler signature for response to any update-state call.delegate void UpdateStateCallback
(StateUpdate Response)
UpdateStateWithIntegerPerform the given Operation on the value of the key at the given Path.UInt16 UpdateStateWithInteger
(string Target, string Operation, string Path, Int64 Value)
UpdateStateWithDoublePerform the given Operation on the value of the key at the given Path.UInt16 UpdateStateWithDouble
(string Target, string Operation, string Path, Double Value)
UpdateStateWithStringPerform the given Operation on the value of the key at the given Path.UInt16 UpdateStateWithString
(string Target, string Operation, string Path, string Value)
UpdateStateWithLiteralPerform the given Operation on the value of the key at the given Path.UInt16 UpdateStateWithLiteral
(string Target, string Operation, string Path, string JsonLiteral)
UpdateStateWithNullPerform the given Operation on the value of the key at the given Path.UInt16 UpdateStateWithNull
(string Target, string Operation, string Path)

Extension and Channel Configuration Handling

An extension can define its own configuration options, on a per-channel or per-extension basis, and store them separately from the standard state store. Each store contains key-value pairs in a JSON object.

  • For all calls, the target is one of CONFIG_TARGET_CHANNEL, CONFIG_TARGET_EXTENSION
  • For update calls, the operation is one of: “add”, “remove”, “replace”, “move”, “copy”, “test”.

There are separate calls for storing state values of specific data types. These take the path to a key within the current JSON object, and a new value of the given type for that key.

Get and update calls are asynchronous. You must supply a callback to handle the response when the operation has completed.

You can subscribe to and unsubscribe from events for specific state targets; see Event Handling.

FunctionDescriptionC# Signature
SetChannelConfigSets channel or extension configuration.UInt16 SetChannelConfig
(string JsonLiteral)
GetChannelConfigRetrieve channel or extension configuration.UInt16 GetChannelConfig
(string Target, GetChannelCallback Callback)
GetChannelCallbackHandler signature for response to GetChannelConfig() call.delegate void GetChannelCallback
(ConfigResponse Response)
UpdateConfigWithIntegerPerform the given Operation on the value of the key at the given Path.UInt16 UpdateConfigWithInteger
(string Target, string Operation, string Path, Int64 Value)
UpdateConfigWithDoublePerform the given Operation on the value of the key at the given Path.UInt16 UpdateConfigWithDouble
(string Target, string Operation, string Path, Double Value)
UpdateConfigWithStringPerform the given Operation on the value of the key at the given Path.UInt16 UpdateConfigWithString (string*Target*,string*Operation*,string*Path*,string` Value)
UpdateConfigWithLiteralPerform the given Operation on the value of the key at the given Path.UInt16 UpdateConfigWithLiteral
(string Target, string Operation, string Path, string JsonLiteral)
UpdateConfigWithNullPerform the given Operation on the value of the key at the given Path.UInt16 UpdateConfigWithNull
(string Target, string Operation, string Path)