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

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.

FunctionDescriptionC# Signature
OnDebugMessageCallbackHandler signature for response to error notification.

The Message contains the error number and description in JSON format.
delegate void OnDebugMessageCallback
(String Message)
OnDebugMessageAttach callback for debug messages.void OnDebugMessage
(OnDebugMessageCallback Callback)
DetachOnDebugMessageDetach 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.

FunctionDescriptionC# Signature
SendBroadcastBroadcasts 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)
DatastreamCallbackHandler signature for response to a message notification.delegate void DatastreamCallback (DatastreamUpdate Update)
OnDatastreamAttach callback for message notification events.

Use SubscribeToDatastream() to begin receiving message notifications.
UInt32 OnDatastream (DatastreamCallback Callback)
DetachOnDatastreamAttach callback for message notification events, passing the Handle returned from OnDatastream().void DetachOnDatastream (UInt32 Handle)
SubscribeToDatastreamSubscribe to message notifications.

Use after defining and attaching a handler with OnDatastream()
UInt16 SubscribeToDatastream ()
UnsubscribeFromDatastreamUnsubscribe 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.

See State and Configuration Handling.

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 or CONFIG_TARGET_EXTENSION.
  • Update notifications report the type of operation performed. Update operations are: “add”, “remove”, “replace”, “move”, “copy”, “test”.
FunctionDescriptionC# Signature
UpdateStateCallbackHandler signature for response to any update-state event.delegate void UpdateStateCallback
(StateUpdate Response)
OnStateUpdateAttach callback for state update events.

Use SubscribeToStateUpdates() to begin receiving update notifications.
UInt32 OnStateUpdate
(UpdateStateCallback Callback)
DetachOnStateUpdateDetach callback for state updates, passing the Handle returned from OnStateUpdate().void DetachOnStateUpdate
(UInt32 Handle)
SubscribeToStateUpdatesSubscribe to state update notifications for channel or extension.

Use after defining and attaching a handler with OnStateUpdate().
UInt16 SubscribeToStateUpdates
(string Target)
UnsubscribeFromStateUpdatesUnsubscribe from state update notifications.UInt16 UnsubscribeFromStateUpdates
(string Target)
UpdateConfigCallbackHandler signature for response to any update-configuration event.delegate void UpdateConfigCallback
(ConfigUpdate Response)
OnConfigUpdateAttach callback for configuration update events.

Use SubscribeToConfigUpdates() to begin receiving update notifications.
UInt32 OnConfigUpdate
(UpdateConfigCallback Callback)
DetachOnConfigUpdateDetach callback for configuration updates, passing the Handle returned from OnConfigUpdate().void DetachOnConfigUpdate
(UInt32 Handle)
SubscribeToConfigurationChangesSubscribe to configuration change notifications.

Use after defining and attaching a handler with OnConfigUpdate().
UInt16 SubscribeToConfigurationChanges (string Target)
UnsubscribeFromConfigurationChangesUnsubscribe 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.

CreatePollCreate 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)
DeletePollDelete the named poll and all its data.

Available only when current user has "admin" role
UInt16 DeletePoll
(String PollId)
GetPollCallbackHandler signature for response to GetPoll() call.delegate void GetPollCallback
(GetPollResponse Response)
GetPollRetrieve poll results once, and pass them to the Callback handler.UInt16 GetPoll
(String PollId, GetPollCallback Callback)
PollUpdateResponseCallbackHandler signature for response to Poll Update. Pass to OnPollUpdate() call.delegate void PollUpdateResponseCallback
(PollUpdateResponse PResp)
OnPollUpdateSets callback to handle Poll Update events.

You must call to SubscribeToPoll() to begin receiving Poll Update events.
UInt32 OnPollUpdate
(PollUpdateResponseCallback Callback)
DetachOnPollUpdateDetach callback for Poll Update events, using Handle returned from OnPollUpdate() call.void DetachOnPollUpdate
(UInt32 Handle)
SubscribeToPollSubscribe to a named poll.

Before subscribing, use OnPollUpdate () to set the callback that handles polling events.
UInt16 SubscribeToPoll
(String PollId)
UnsubscribeFromPollUnsubscribe from the named poll.UInt16 UnsubscribeFromPoll
(String PollId)

Twitch Bit Transactions

The following SDK functions let you manage Twitch Bit Transactions from extension viewers.

FunctionDescriptionC# Signature
SubscribeToSKUSubscribe to SKU purchase notifications.UInt16 SubscribeToSKU
(string SKU)
UnsubscribeFromSKUUnsubscribe from SKU purchase notifications.UInt16 UnsubscribeFromSKU
(string SKU)
SubscribeToAllPurchasesSubscribe to all Twitch Bit Purchase notifications.UInt16 SubscribeToAllPurchases ()
UnsubscribeFromAllPurchasesUnsubscribe from all Twitch Bit Purchase notifications.UInt16 UnsubscribeFromAllPurchases ()
TransactionCallbackHandler signature for response to purchase events. Pass to OnTransaction() call.delegate void TransactionCallback
(Transaction Purchase)
OnTransactionSets callback for Twitch Bit Purchasing events.

You must subscribe by calling to SubscribeToSKU() or SubscribeToAllPurchases() to begin receiving purchase events.
UInt32 OnTransaction
(TransactionCallback Callback)
DetachOnTransactionDetach callback for Twitch Bit Purchases using Handle returned from OnTransaction() call.void DetachOnTransaction
` (UInt32 Handle)
GetOutstandingTransactionsCallbackHandler signature for response to GetOutstandingTransactions() calls.delegate void GetOutstandingTransactionsCallback
(OutstandingTransactions Transactions)
GetOutstandingTransactionsGet all outstanding transactions that need validation.UInt16 GetOutstandingTransactions
(String SKU, GetOutstandingTransactionsCallback Callback)
RefundTransactionByIDRefund given transaction for user.UInt16 RefundTransactionByID
(String TxId, String UserId)
RefundTransactionBySKURefund given transaction for user.UInt16 RefundTransactionBySKU
(String SKU, String UserId)
ValidateTransactionValidate given transaction.UInt16 ValidateTransaction
(String TxId, String Details)