示例#1
0
        public async void RetrieveStreamTest()
        {
            bool   streamOffline = false;
            Stream stream        = null;

            // This stream may be offline so it is suggested you edit
            // this line to get a stream that is online.
            stream = await twixel.RetrieveStream((await twixel.GetUserId("monstercat")).ToString());

            if (stream != null)
            {
                Assert.Equal("Music", stream.game);
            }
            else
            {
                Assert.True(streamOffline);
            }

            TwixelException ex = await Assert.ThrowsAsync <TwixelException>(async() => await twixel.RetrieveStream("ETdfdsfjldsjdfs"));

            Assert.IsType(typeof(TwixelException), ex);

            ex = await Assert.ThrowsAsync <TwixelException>(async() => await twixel.RetrieveStream("22747608"));

            Assert.Equal("22747608 is offline", ex.Message);
        }
示例#2
0
        public async void RetrieveStreamTest()
        {
            bool   streamOffline = false;
            Stream stream        = null;

            // This stream may be offline so it is suggested you edit
            // this line to get a stream that is online.
            stream = await twixel.RetrieveStream("saltyteemo");

            if (stream != null)
            {
                Assert.Equal("League of Legends", stream.game);
            }
            else
            {
                Assert.True(streamOffline);
            }

            TwixelException ex = await Assert.ThrowsAsync <TwixelException>(async() => await twixel.RetrieveStream("ETdfdsfjldsjdfs"));

            Assert.IsType(typeof(TwitchException), ex.InnerException);
            Assert.Equal(404, ((TwitchException)ex.InnerException).Status);

            ex = await Assert.ThrowsAsync <TwixelException>(async() => await twixel.RetrieveStream("golf1052"));

            Assert.Equal("golf1052 is offline", ex.Message);
        }
示例#3
0
        public async void RetrieveStreamTest()
        {
            bool streamOffline = false;

            twixel.TwixelErrorEvent += (o, e) => streamOffline = true;
            Stream stream = null;

            // This stream may be offline so it is suggested you edit
            // this line to get a stream that is online.
            stream = await twixel.RetrieveStream("imaqtpie");

            if (stream != null)
            {
                Assert.Equal("League of Legends", stream.game);
            }
            else
            {
                Assert.True(streamOffline);
            }

            bool myStreamOffline = false; // will probably always be false

            twixel.TwixelErrorEvent += (o, e) => myStreamOffline = true;
            stream = await twixel.RetrieveStream("golf1052");

            Assert.True(myStreamOffline);
        }
        public static async Task <long?> GetViewerCount()
        {
            var twixel = new Twixel("iy9ihx1dt50wo7jsb5p8tv5kvpd1yvq", "http://localhost");
            var stream = await twixel.RetrieveStream("brentschooley");

            return(stream.viewers);
        }
示例#5
0
        private async void updateStreamInfo()
        {
            Debug.Print("Update Stream Info");
            Stream twitchStream = null;

            try
            {
                twitchStream = await twitchClient.RetrieveStream(twitchUser.name.ToString());

                LogitechArx.LogiArxSetTagContentById("average_fps", twitchStream.averageFps.ToString());
                LogitechArx.LogiArxSetTagContentById("game", twitchStream.game.ToString());
                LogitechArx.LogiArxSetTagContentById("viewers", twitchStream.viewers.ToString());
                LogitechArx.LogiArxSetTagContentById("video_quality", twitchStream.videoHeight.ToString() + "p");
                LogitechArx.LogiArxSetTagContentById("status", twitchChannel.status.ToString());
                if (twitchChannel.delay.ToString() != "")
                {
                    LogitechArx.LogiArxSetTagContentById("delay", twitchChannel.delay.ToString());
                }
                else
                {
                    LogitechArx.LogiArxSetTagContentById("delay", "None");
                }
            }
            catch
            {
                LogitechArx.LogiArxSetTagContentById("average_fps", "");
                LogitechArx.LogiArxSetTagContentById("game", "");
                LogitechArx.LogiArxSetTagContentById("viewers", "");
                LogitechArx.LogiArxSetTagContentById("video_quality", "");
                LogitechArx.LogiArxSetTagContentById("status", "Stream offline!");
                LogitechArx.LogiArxSetTagContentById("delay", "");
            }


            if (twitchChannel != null)
            {
                if (!twitchChannel.partner.Value)
                {
                    LogitechArx.LogiArxSetTagPropertyById("commercial_card", "hidden", "true");
                }
            }
        }