TwitchLib / TwitchLib.Unity

TwitchLib repository representing all code belonging to the implementation of TwitchLib for Unity. Maintained primarily by LuckyNoS7evin.
164 stars 33 forks source link

The PubSub sample code does not work. #30

Closed 677283 closed 6 years ago

677283 commented 6 years ago

The PubSub sample code does not work.

I used my twitch ID and my Oauth.

But there is no reaction at all.

I was not a partner streamer, so I tested Ban.

This is the example code.

Am I using it wrong?


using UnityEngine; using TwitchLib.Unity; using System; using TwitchLib.PubSub.Events;

public class TwitchPubSubExample : MonoBehaviour { private PubSub _client;

void Start()
{
    //Set to run in minimized mode
    Application.runInBackground = true;
    //Create new instance of PubSub Client
    _client = new PubSub();
    //Subscribe to Events
    _client.OnBan += BanTest;
    _client.OnBitsReceived += _client_OnBitsReceived;
    _client.OnPubSubServiceConnected += _client_OnPubSubServiceConnected;
    //Connect
    _client.Connect();

}

private void BanTest(object sender, OnBanArgs e)
{
    Debug.Log(e.BannedUserId + ":: BAN");
}

private void _client_OnPubSubServiceConnected(object sender, System.EventArgs e)
{
    //On connect listen to Bits event
    _client.ListenToBitsEvents("ID");
    _client.ListenToChatModeratorActions("ID", "ID");
    _client.SendTopics("oauth");
}

private void _client_OnBitsReceived(object sender, TwitchLib.PubSub.Events.OnBitsReceivedArgs e)
{
    //Do your bits logic here.
}

}

swiftyspiffy commented 6 years ago

@677283 if you don't mind me asking, what was the problem/solution?

677283 commented 6 years ago

@swiftyspiffy Sorry. I've fixed the issue. It was my mistake.

swiftyspiffy commented 6 years ago

Awesome, cheers!