Twitchlib PubSub 看不到事件
Twitchlib PubSub cant see events
我正在尝试收听预测和渠道积分奖励。但是 PubSub 完全沉默,我不明白为什么。
using TwitchLib.PubSub;
using TwitchLib.PubSub.Events;
namespace PubSub_app
{
class PubSub
{
TwitchPubSub client;
public PubSub()
{
client = new TwitchPubSub();
client.OnPubSubServiceConnected += Pubsub_OnPubSubServiceConnected;
client.OnChannelPointsRewardRedeemed += Pubsub_OnChannelPointsRewardRedeemed;
client.OnPrediction += Pubsub_OnPrediction;
client.Connect();
}
private void Pubsub_OnPubSubServiceConnected(object sender, System.EventArgs e)
{
client.ListenToChannelPoints("62651386");
client.ListenToPredictions("62651386");
Console.WriteLine("PubSub Connected");
}
private void Pubsub_OnPrediction(object sender, OnPredictionArgs e)
{
Console.WriteLine("Prediction");
Console.WriteLine(e.Title);
}
private void Pubsub_OnChannelPointsRewardRedeemed(object sender, OnChannelPointsRewardRedeemedArgs e)
{
Console.WriteLine("Points redeemed");
Console.WriteLine(e.RewardRedeemed);
}
}
}
控制台唯一显示其已连接
您缺少 Pubsub_OnPubSubServiceConnected
中的 client.SendTopics(accessToken);
行。
我正在尝试收听预测和渠道积分奖励。但是 PubSub 完全沉默,我不明白为什么。
using TwitchLib.PubSub;
using TwitchLib.PubSub.Events;
namespace PubSub_app
{
class PubSub
{
TwitchPubSub client;
public PubSub()
{
client = new TwitchPubSub();
client.OnPubSubServiceConnected += Pubsub_OnPubSubServiceConnected;
client.OnChannelPointsRewardRedeemed += Pubsub_OnChannelPointsRewardRedeemed;
client.OnPrediction += Pubsub_OnPrediction;
client.Connect();
}
private void Pubsub_OnPubSubServiceConnected(object sender, System.EventArgs e)
{
client.ListenToChannelPoints("62651386");
client.ListenToPredictions("62651386");
Console.WriteLine("PubSub Connected");
}
private void Pubsub_OnPrediction(object sender, OnPredictionArgs e)
{
Console.WriteLine("Prediction");
Console.WriteLine(e.Title);
}
private void Pubsub_OnChannelPointsRewardRedeemed(object sender, OnChannelPointsRewardRedeemedArgs e)
{
Console.WriteLine("Points redeemed");
Console.WriteLine(e.RewardRedeemed);
}
}
}
控制台唯一显示其已连接
您缺少 Pubsub_OnPubSubServiceConnected
中的 client.SendTopics(accessToken);
行。