Exemplo n.º 1
0
        /// <summary>
        /// Livetube用Main(テスト用に差し替え可能な形)
        /// </summary>
        /// <param name="clientFactory">使用するILivetubeClientのインスタンスを選択</param>
        /// <param name="pso2Factory">使用するIPso2LogWatcherのインスタンスを選択</param>
        /// <param name="waitAction">プログラムの終了を待つためのActionを選択</param>
        public static void LivetubeMain(
            ILivetubeClientFactory clientFactory,
            IPso2LogWatcherFactory pso2Factory,
            Action waitAction)
        {
            using (ILivetubeClient livetube = clientFactory.CreateLivetubeClient())
            {
                string userurl      = new Uri(String.Format("http://livetube.cc/{0}/", USER)).AbsoluteUri;
                string broadcastUrl = livetube.FindCurrentBroadcasting(userurl);
                if (broadcastUrl == null)
                {
                    throw new ApplicationException("現配信URLの取得に失敗しました");
                }
                string stream = livetube.FindStream(broadcastUrl);
                if (stream == null)
                {
                    throw new ApplicationException("ストリームの取得に失敗しました");
                }

                livetube.Login(USER, PASSWORD);

                LogWatch(
                    (string user, string message) =>
                {
                    livetube.PostComment(stream, user, message);
                },
                    waitAction,
                    pso2Factory
                    );

                livetube.Logoff();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Livetube用Main(テスト用に差し替え可能な形)
        /// </summary>
        /// <param name="clientFactory">使用するILivetubeClientのインスタンスを選択</param>
        /// <param name="pso2Factory">使用するIPso2LogWatcherのインスタンスを選択</param>
        /// <param name="waitAction">プログラムの終了を待つためのActionを選択</param>
        public static void LivetubeMain(
            ILivetubeClientFactory clientFactory,
            IPso2LogWatcherFactory pso2Factory,
            Action waitAction)
        {
            using (ILivetubeClient livetube = clientFactory.CreateLivetubeClient())
            {
                string userurl = new Uri(String.Format("http://livetube.cc/{0}/", USER)).AbsoluteUri;
                string broadcastUrl = livetube.FindCurrentBroadcasting(userurl);
                if (broadcastUrl == null)
                    throw new ApplicationException("現配信URLの取得に失敗しました");
                string stream = livetube.FindStream(broadcastUrl);
                if (stream == null)
                    throw new ApplicationException("ストリームの取得に失敗しました");

                livetube.Login(USER, PASSWORD);

                LogWatch(
                    (string user, string message) =>
                    {
                        livetube.PostComment(stream, user, message);
                    },
                    waitAction,
                    pso2Factory
                );

                livetube.Logoff();
            }
        }