SDK functions for managing subscriptions and handling of event notification in all areas.
Muxy offers client-server and server-to-server communication through a messaging service. Extensions can publish and subscribe to messages on a named thread, and users with the "admin" role can broadcast messages to all viewers, or to selected sets of viewers.
Event subscriptions and notifications are handled slightly differently in different areas:
- Debugging events report error information in the development environment.
- Datastream events provide generic pub-sub message broadcasting.
- State and configuration events report activity that affects stored state and configuration values for an extension.
- Polling events report activity in a named viewer poll.
- Transaction events report Twitch Bit Transaction activity involving an extension user.
Debugging events
In the development environment, the server reports errors through these messages. The extension does not need to subscribe, but must supply a handler for the error information contained in the message.
Function | Description | C# Signature |
---|---|---|
OnDebugMessageCallback | Handler signature for response to error notification. The Message contains the error number and description in JSON format. | delegate void OnDebugMessageCallback (String Message) |
OnDebugMessage | Attach callback for debug messages. | void OnDebugMessage (OnDebugMessageCallback Callback) |
DetachOnDebugMessage | Detach callback for debug messages. | void DetachOnDebugMessage () |
Datastream events
This system provides the ability to broadcast messages to subscribers on a per-channel or per-extension basis. Notification of broadcasts on the datastream contain the arbitrary message content in JSON format.
Function | Description | C# Signature |
---|---|---|
SendBroadcast | Broadcasts a message to subscribers in the Target scope, one of "STATE_TARGET_CHANNEL" or "STATE_TARGET_EXTENSION". Json contains the message body in JSON format. | UInt16 SendBroadcast (string Target, string Json) |
DatastreamCallback | Handler signature for response to a message notification. | delegate void DatastreamCallback (DatastreamUpdate Update) |
OnDatastream | Attach callback for message notification events. Use SubscribeToDatastream() to begin receiving message notifications. | UInt32 OnDatastream (DatastreamCallback Callback) |
DetachOnDatastream | Attach callback for message notification events, passing the Handle returned from OnDatastream() . | void DetachOnDatastream (UInt32 Handle) |
SubscribeToDatastream | Subscribe to message notifications. Use after defining and attaching a handler with OnDatastream() | UInt16 SubscribeToDatastream () |
UnsubscribeFromDatastream | Unsubscribe from message notifications. | UInt16 UnsubscribeFromDatastream () |
State and Configuration Events
Muxy stores predefined and developer-defined state values on a per-channel or per-extension basis.
An extension can also 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.
Use the following functions to manage subscriptions and define responses to state and configuration update notifications.
- Subscription-management functions must specify the target, one of
CONFIG_TARGET_CHANNEL
orCONFIG_TARGET_EXTENSION
. - Update notifications report the type of operation performed. Update operations are: “add”, “remove”, “replace”, “move”, “copy”, “test”.
Function | Description | C# Signature |
---|---|---|
UpdateStateCallback | Handler signature for response to any update-state event. | delegate void UpdateStateCallback (StateUpdate Response) |
OnStateUpdate | Attach callback for state update events. Use SubscribeToStateUpdates() to begin receiving update notifications. | UInt32 OnStateUpdate (UpdateStateCallback Callback) |
DetachOnStateUpdate | Detach callback for state updates, passing the Handle returned from OnStateUpdate() . | void DetachOnStateUpdate (UInt32 Handle) |
SubscribeToStateUpdates | Subscribe to state update notifications for channel or extension. Use after defining and attaching a handler with OnStateUpdate() . | UInt16 SubscribeToStateUpdates (string Target) |
UnsubscribeFromStateUpdates | Unsubscribe from state update notifications. | UInt16 UnsubscribeFromStateUpdates (string Target) |
UpdateConfigCallback | Handler signature for response to any update-configuration event. | delegate void UpdateConfigCallback (ConfigUpdate Response) |
OnConfigUpdate | Attach callback for configuration update events. Use SubscribeToConfigUpdates() to begin receiving update notifications. | UInt32 OnConfigUpdate (UpdateConfigCallback Callback) |
DetachOnConfigUpdate | Detach callback for configuration updates, passing the Handle returned from OnConfigUpdate() . | void DetachOnConfigUpdate (UInt32 Handle) |
SubscribeToConfigurationChanges | Subscribe to configuration change notifications. Use after defining and attaching a handler with OnConfigUpdate() . | UInt16 SubscribeToConfigurationChanges (string Target) |
UnsubscribeFromConfigurationChanges | Unsubscribe from configuration change notifications. | UInt16 UnsubscribeFromConfigurationChanges (string Target) |
Manage Polls and Polling Events
Users with administrative privilege can create and manage viewer polls. Use these SDK
functions manage subscriptions to polling events, and get poll responses.
Function | Description | Signature |
---|---|---|
CreatePoll | Create and name a poll, with a prompt and list of options. Available only when current user has "admin" role. | UInt16 CreatePoll (String PollId, String Prompt, List< String > Options) |
DeletePoll | Delete the named poll and all its data. Available only when current user has "admin" role | UInt16 DeletePoll (String PollId) |
GetPollCallback | Handler signature for response to GetPoll() call. | delegate void GetPollCallback (GetPollResponse Response) |
GetPoll | Retrieve poll results once, and pass them to the Callback handler. | UInt16 GetPoll (String PollId, GetPollCallback Callback) |
PollUpdateResponseCallback | Handler signature for response to Poll Update. Pass to OnPollUpdate() call. | delegate void PollUpdateResponseCallback (PollUpdateResponse PResp) |
OnPollUpdate | Sets callback to handle Poll Update events. You must call to SubscribeToPoll() to begin receiving Poll Update events. | UInt32 OnPollUpdate (PollUpdateResponseCallback Callback) |
DetachOnPollUpdate | Detach callback for Poll Update events, using Handle returned from OnPollUpdate() call. | void DetachOnPollUpdate (UInt32 Handle) |
SubscribeToPoll | Subscribe to a named poll. Before subscribing, use OnPollUpdate () to set the callback that handles polling events. | UInt16 SubscribeToPoll (String PollId) |
UnsubscribeFromPoll | Unsubscribe from the named poll. | UInt16 UnsubscribeFromPoll (String PollId) |
Twitch Bit Transactions
The following SDK
functions let you manage Twitch Bit Transactions from extension viewers.
Function | Description | C# Signature |
---|---|---|
SubscribeToSKU | Subscribe to SKU purchase notifications. | UInt16 SubscribeToSKU (string SKU) |
UnsubscribeFromSKU | Unsubscribe from SKU purchase notifications. | UInt16 UnsubscribeFromSKU (string SKU) |
SubscribeToAllPurchases | Subscribe to all Twitch Bit Purchase notifications. | UInt16 SubscribeToAllPurchases () |
UnsubscribeFromAllPurchases | Unsubscribe from all Twitch Bit Purchase notifications. | UInt16 UnsubscribeFromAllPurchases () |
TransactionCallback | Handler signature for response to purchase events. Pass to OnTransaction() call. | delegate void TransactionCallback (Transaction Purchase) |
OnTransaction | Sets callback for Twitch Bit Purchasing events. You must subscribe by calling to SubscribeToSKU() or SubscribeToAllPurchases() to begin receiving purchase events. | UInt32 OnTransaction (TransactionCallback Callback) |
DetachOnTransaction | Detach callback for Twitch Bit Purchases using Handle returned from OnTransaction() call. | void DetachOnTransaction ` (UInt32 Handle) |
GetOutstandingTransactionsCallback | Handler signature for response to GetOutstandingTransactions() calls. | delegate void GetOutstandingTransactionsCallback (OutstandingTransactions Transactions) |
GetOutstandingTransactions | Get all outstanding transactions that need validation. | UInt16 GetOutstandingTransactions (String SKU, GetOutstandingTransactionsCallback Callback) |
RefundTransactionByID | Refund given transaction for user. | UInt16 RefundTransactionByID (String TxId, String UserId) |
RefundTransactionBySKU | Refund given transaction for user. | UInt16 RefundTransactionBySKU (String SKU, String UserId) |
ValidateTransaction | Validate given transaction. | UInt16 ValidateTransaction (String TxId, String Details) |