コード例 #1
0
        private async Task Calls()
        {
            try
            {
                ConnectionCredentials credentials = new ConnectionCredentials("lix_danssonlabo", "AccessToken");
                var clientOptions = new ClientOptions
                {
                    MessagesAllowedInPeriod = 750,
                    ThrottlingPeriod        = TimeSpan.FromSeconds(30)
                };
                WebSocketClient customClient = new WebSocketClient(clientOptions);
                client = new TwitchClient(customClient);
                client.Initialize(credentials, "lix_danssonlabo");
                client.OnLog             += Client_OnLog;
                client.OnJoinedChannel   += Client_OnJoinedChannel;
                client.OnMessageReceived += Client_OnMessageReceived;
                client.OnWhisperReceived += Client_OnWhisperReceived;
                client.OnNewSubscriber   += Client_OnNewSubscriber;
                client.OnConnected       += Client_OnConnected;

                client.Connect();

                Chan = await api.V5.Channels.GetChannelAsync("AccessToken");

                liveState.Checked = await api.V5.Streams.BroadcasterOnlineAsync(Chan.Id);

                clientPubSub = new TwitchPubSub();

                clientPubSub.OnPubSubServiceConnected += onPubSubServiceConnected;
                clientPubSub.OnPrediction             += OnPubSubPrediction;
                clientPubSub.OnListenResponse         += onListenResponse;

                clientPubSub.ListenToPredictions(Chan.Id);
                clientPubSub.Connect();

                OnLineTime.Text = $"Online since : {await api.V5.Streams.GetUptimeAsync(Chan.Id)}";
            }
            catch (Exception e)
            {
                MessageBox.Show($"[Exception] {e}");
            }
        }
コード例 #2
0
 private void ListenToPredictions(string channelId)
 {
     PubSub.OnPrediction += PubSub_OnPrediction;
     PubSub.ListenToPredictions(channelId);
 }