Class TwitchPubSub
- Namespace
- Firesplash.UnityAssets.TwitchIntegration.Skeletons
- Assembly
- Firesplash.UnityAssets.TwitchIntegration.dll
This class provides access to the PubSub features
public class TwitchPubSub
- Inheritance
-
TwitchPubSub
- Derived
- Inherited Members
Fields
DebugMode
Setting this to true will cause detailed log output. It's made for development only.
public bool DebugMode
Field Value
OnBitsBadgeUnlock
This event is fired, when a Bits Badge Unlock message is received (channel-bits-badge-unlocks). We extend Twitch's json structure by a field "Topic" that contains the exact topic, the message was received for.
public TwitchPubSub.BitsBadgeUnlockEvent OnBitsBadgeUnlock
Field Value
OnBitsEvent
This event is fired, when a Bit Message V1 or V2 Event is received (channel-bits-events-v1 or channel-bits-events-v2). Hint: The data structure of V1 and V2 is shared, V2 simply omits transmitting some data if unapplicable so those fields might be null. You can control whether you want to receive V1, V2 or both through your subscription. You can detect the v1 or v2 type by parsing the Topic field we add to the event
public TwitchPubSub.BitsEvent OnBitsEvent
Field Value
OnCommerceEvent
This event is fired, when a Channel Points Event is received We extend Twitch's json structure by a field "Topic" that contains the exact topic, the message was received for.
public TwitchPubSub.CommerceEvent OnCommerceEvent
Field Value
OnConnectionEstablished
This event is fired, when the connection becomes ready. The perfect place to send your subscriptions. Please note that this is also called on a reconnect and you have to re-subscribe on such a reconnect event! Remember that tokens do not last infinitely!
[HideInInspector]
public UnityEvent OnConnectionEstablished
Field Value
- UnityEvent
OnDisconnect
This event is fired, when the connection is closed. The boolean parameter is true, when the disconnect was expectd and false if not. Actually true means, no auto reconnect while false means a reconnect will take place. Under some circumstances, this event MIGHT fire multiple times for a single disconnect.
[HideInInspector]
public UnityEvent<bool> OnDisconnect
Field Value
- UnityEvent<bool>
OnError
This event is fired, whenever an error occures during the work of the PubSub-Thread. It's argument is the Exception which is thrown.
public TwitchPubSub.ErrorEvent OnError
Field Value
OnGenericEvent
This is a generic event. Every message that is received on the PubSub is sent out using this event in it's original String-Form (data -> message) with no parsing. You can use this to even subscribe to Events which are not handled by this library natively. The second string is the topic, we received the message under.
public TwitchPubSub.GenericEvent OnGenericEvent
Field Value
OnHypeTrainLevelUp
This event is fired, when a Hype Train evolves to the enxt level We extend Twitch's json structure by a field "Topic" that contains the exact topic, the message was received for.
public TwitchPubSub.HypeTrainLevelUpEvent OnHypeTrainLevelUp
Field Value
OnHypeTrainProgress
This event is fired, when a Hype Train makes progress (for every action that contributes to the Hype Train) We extend Twitch's json structure by a field "Topic" that contains the exact topic, the message was received for.
public TwitchPubSub.HypeTrainProgressEvent OnHypeTrainProgress
Field Value
OnNewFollowerEvent
This event is fired, when a Channel Points Event is received We extend Twitch's json structure by a field "Topic" that contains the exact topic, the message was received for.
[Obsolete("The NewFollower-Event is no longer available as it has been removed by twitch. It's methods will be removed in a future release.")]
public TwitchPubSub.NewFollowerEvent OnNewFollowerEvent
Field Value
OnPointRewardEvent
This event is fired, when a Channel Points Event is received We extend Twitch's json structure by a field "Topic" that contains the exact topic, the message was received for.
public TwitchPubSub.PointRewardEvent OnPointRewardEvent
Field Value
OnSubscribeEvent
This event is fired, when a Channel Points Event is received We extend Twitch's json structure by a field "Topic" that contains the exact topic, the message was received for.
public TwitchPubSub.SubscribeEvent OnSubscribeEvent
Field Value
OnTopicSubscriptionConfirmed
This event is fired when a subscription gets confirmed by the server. The string[] it brings is the array of topics you subscribed successfully to.
public TwitchPubSub.TopicSubscriptionConfirmedEvent OnTopicSubscriptionConfirmed
Field Value
OnTopicSubscriptionDeclined
This event is fired when a subscription gets confirmed by the server. The string[] it brings is the array of topics you tried to subscribe to. The second string is the error message sent by Twitch.
public TwitchPubSub.TopicSubscriptionDeclinedEvent OnTopicSubscriptionDeclined
Field Value
OnWhisper
This event is fired, when a Channel Points Event is received We extend Twitch's json structure by a field "Topic" that contains the exact topic, the message was received for.
public TwitchPubSub.WhisperEvent OnWhisper
Field Value
suppressExperimentalFeatureWarnings
If you set this to true, it will suppredd Debug.LogWarning-Outputs about using experimental or undocumented features. Recommendation: Don't do this. Really. I mean it.
public bool suppressExperimentalFeatureWarnings
Field Value
Methods
Connect()
Actually connects to the servers.
public void Connect()
SubscribeGeneric(string[], string)
Using this subscription, you can subscribe to any PubSub event - even if not yet supported by this library natively. Instead as a filtered Object you will receive the complete JSON "message" sent by twitch through PubSubGenericEvent as the second Event parameter (as a string). Subscriptions may only be made after a successful connection. Use OnConnectionEstablished-Event!
public void SubscribeGeneric(string[] topics, string oAuthToken)
Parameters
topics
string[]The Topics to subscribe according to Twitch's documentation packaged as an array of strings
oAuthToken
stringThe oAuth Bearer Token to use for connecting - The token must be eligible for the required scopes.
SubscribeToBitsBadgeNotifications(string, string)
Subscribes to the Topic required to receive Bits Badge Notifications
public void SubscribeToBitsBadgeNotifications(string channel, string oAuthToken)
Parameters
channel
stringThe channel ID you want to receive events for
oAuthToken
stringThe authorized oAuth token to use for subscription
SubscribeToBitsBadgeNotifications(string[], string)
Subscribes to the Topic required to receive Bits Badge Notifications
public void SubscribeToBitsBadgeNotifications(string[] channels, string oAuthToken)
Parameters
channels
string[]An Array of strings containing channel IDs
oAuthToken
stringThe authorized oAuth token to use for subscription
SubscribeToBitsEventsV1(string, string)
Subscribes to the Topic required to receive Bits V1 Events
public void SubscribeToBitsEventsV1(string channel, string oAuthToken)
Parameters
channel
stringThe channel ID you want to receive events for
oAuthToken
stringThe authorized oAuth token to use for subscription
SubscribeToBitsEventsV1(string[], string)
Subscribes to the Topic required to receive Bits V1 Events
public void SubscribeToBitsEventsV1(string[] channels, string oAuthToken)
Parameters
channels
string[]An Array of strings containing channel IDs
oAuthToken
stringThe authorized oAuth token to use for subscription
SubscribeToBitsEventsV2(string, string)
Subscribes to the Topic required to receive Bits V2 Events
public void SubscribeToBitsEventsV2(string channel, string oAuthToken)
Parameters
channel
stringThe channel ID you want to receive events for
oAuthToken
stringThe authorized oAuth token to use for subscription
SubscribeToBitsEventsV2(string[], string)
Subscribes to the Topic required to receive Bits V2 Events
public void SubscribeToBitsEventsV2(string[] channels, string oAuthToken)
Parameters
channels
string[]An Array of strings containing channel IDs
oAuthToken
stringThe authorized oAuth token to use for subscription
SubscribeToChannelPointsEvents(string, string)
Subscribes to the Topic required to receive Channel Points Events
public void SubscribeToChannelPointsEvents(string channel, string oAuthToken)
Parameters
channel
stringThe channel ID you want to receive events for
oAuthToken
stringThe authorized oAuth token to use for subscription
SubscribeToChannelPointsEvents(string[], string)
Subscribes to the Topic required to receive Channel Points Events
public void SubscribeToChannelPointsEvents(string[] channels, string oAuthToken)
Parameters
channels
string[]An Array of strings containing channel IDs
oAuthToken
stringThe authorized oAuth token to use for subscription
SubscribeToChannelSubscriptions(string, string)
Subscribes to the Topic required to receive Channel Subscriptions
public void SubscribeToChannelSubscriptions(string channel, string oAuthToken)
Parameters
channel
stringThe channel ID you want to receive events for
oAuthToken
stringThe authorized oAuth token to use for subscription
SubscribeToChannelSubscriptions(string[], string)
Subscribes to the Topic required to receive Channel Subscriptions
public void SubscribeToChannelSubscriptions(string[] channels, string oAuthToken)
Parameters
channels
string[]An Array of strings containing channel IDs
oAuthToken
stringThe authorized oAuth token to use for subscription
SubscribeToHypeTrains(string, string)
Subscribes to the Topic required to receive Whispers
public void SubscribeToHypeTrains(string user, string oAuthToken)
Parameters
user
stringThe user ID you want to receive whispers for
oAuthToken
stringThe authorized oAuth token to use for subscription
SubscribeToHypeTrains(string[], string)
!!! EXPERIMENTAL UNOFFICIAL API !!! Subscribes to the Topic required to receive Hype Train events. This topic is undocumented so using it might work, crash your app or cause an atomic war. Use at your own risk.
public void SubscribeToHypeTrains(string[] users, string oAuthToken)
Parameters
users
string[]An Array of strings containing user IDs
oAuthToken
stringThe authorized oAuth token to use for subscription
SubscribeToNewFollowers(string, string)
This topic is no longer supported by twitch. Subscribes to the Topic required to receive new Followers
[Obsolete("The NewFollower-Event is no longer available as it has been removed by twitch. It's methods will be removed in a future release.")]
public void SubscribeToNewFollowers(string channel, string oAuthToken)
Parameters
channel
stringThe channel ID you want to receive events for
oAuthToken
stringThe authorized oAuth token to use for subscription
SubscribeToNewFollowers(string[], string)
This topic is no longer supported by twitch. Subscribes to the Topic required to receive new Followers
[Obsolete("The NewFollower-Event is no longer available as it has been removed by twitch. It's methods will be removed in a future release.")]
public void SubscribeToNewFollowers(string[] channels, string oAuthToken)
Parameters
channels
string[]An Array of strings containing channel IDs
oAuthToken
stringThe authorized oAuth token to use for subscription
SubscribeToWhispers(string, string)
Subscribes to the Topic required to receive Whispers
public void SubscribeToWhispers(string user, string oAuthToken)
Parameters
user
stringThe user ID you want to receive whispers for
oAuthToken
stringThe authorized oAuth token to use for subscription
SubscribeToWhispers(string[], string)
Subscribes to the Topic required to receive Whispers
public void SubscribeToWhispers(string[] users, string oAuthToken)