Esempio n. 1
0
 private void CommentProvider_OnReceivedComment(object sender, ReceivedCommentArgs e)
 {
     try
     {
         //DEBUG: 弹幕显示测试
         //InfoLogger.SendInfo(_roomid, "收到弹幕", e.Comment.CommentUser + ": " + e.Comment.CommentText);
         //接收到弹幕时的处理。
         if (e.Comment.MsgType != MsgTypeEnum.LiveStart)
         {
             if (e.Comment.MsgType != MsgTypeEnum.LiveEnd)
             {
                 return;
             }
             InfoLogger.SendInfo(Roomid, "INFO", "[主播结束直播]");
             Stop();
         }
         else
         {
             InfoLogger.SendInfo(Roomid, "INFO", "[主播开始直播]");
             //重新开始下载直播
             force_stoping = true;
             Stop();
             Start();
         }
     }
     catch (Exception ex)
     {
         InfoLogger.SendInfo(Roomid, "ERROR", "在收取弹幕时发生未知错误:" + ex.Message);
     }
 }
Esempio n. 2
0
        private void Init()
        {
            var hkcu = Registry.CurrentUser;

            Debug.Assert(hkcu != null, "hkcu != null");
            hkcu.CreateSubKey("SOFTWARE\\BiliRoku");
            var bilirokuKey = hkcu.OpenSubKey("SOFTWARE\\BiliRoku");

            Debug.Assert(bilirokuKey != null, "bilirokuKey != null");
            var subkeyNames = bilirokuKey.GetValueNames();

            foreach (var keyName in subkeyNames)
            {
                switch (keyName)
                {
                case "version":
                    _version = bilirokuKey.GetValue("version").ToString();
                    break;

                case "room_id":
                    _roomId = bilirokuKey.GetValue("room_id").ToString();
                    break;

                case "is_download_cmt":
                    _isDownloadCmt = bilirokuKey.GetValue("is_download_cmt").ToString();
                    break;

                case "is_wait_streaming":
                    _isWaitStreaming = bilirokuKey.GetValue("is_wait_streaming").ToString();
                    break;

                case "is_auto_retry":
                    _isAutoRetry = bilirokuKey.GetValue("is_auto_retry").ToString();
                    break;

                case "filename":
                    _filename = bilirokuKey.GetValue("filename").ToString();
                    break;

                case "save_path":
                    _savePath = bilirokuKey.GetValue("save_path").ToString();
                    break;

                case "refresh_time":
                    _refreshTime = bilirokuKey.GetValue("refresh_time").ToString();
                    break;

                case "timeout":
                    _timeout = bilirokuKey.GetValue("timeout").ToString();
                    break;

                default:
                    InfoLogger.SendInfo("Config", "WARNING", "不支持的配置项。");
                    break;
                }
            }
            hkcu.Close();
        }
Esempio n. 3
0
        private async void NetErrorFastRetry()
        {
            InfoLogger.SendInfo(Roomid, "INFO", $"网络错误,即将开始重试[重试次数 {retrycount+1}]");
            await Task.Delay(2000);

            if (record_status == false)
            {
                Start();                         //保证同时只有一个下载(否则会下坏)
            }
            retrycount++;
        }
Esempio n. 4
0
        private void CommentProvider_OnDisconnected(object sender, DisconnectEvtArgs e)
        {
            InfoLogger.SendInfo(Roomid, "INFO", "弹幕服务器断开");

            //如果不是用户触发的,则尝试重连。
            if (!force_stoping)
            {
                return;
            }
            InfoLogger.SendInfo(Roomid, "INFO", "尝试重新连接弹幕服务器");
            commentProvider.Connect();
        }
Esempio n. 5
0
        private async void AutoRetry()
        {
            var config = Config.Instance;

            InfoLogger.SendInfo(Roomid, "INFO", "等待 " + config.RefreshTime + " 秒后重试。");
            await Task.Delay(int.Parse(config.RefreshTime ?? "30") * 1000);

            if (record_status == false)
            {
                Start();                        //保证同时只有一个下载(否则会下坏)
            }
        }
Esempio n. 6
0
 private CommentProvider ReceiveComment()
 {
     try
     {
         var _commentProvider = new CommentProvider(realRoomid);
         _commentProvider.OnDisconnected      += CommentProvider_OnDisconnected;
         _commentProvider.OnReceivedRoomCount += CommentProvider_OnReceivedRoomCount;
         _commentProvider.OnReceivedComment   += CommentProvider_OnReceivedComment;
         _commentProvider.Connect();
         return(_commentProvider);
     }
     catch (Exception e)
     {
         InfoLogger.SendInfo(Roomid, "ERROR", "弹幕服务器出错:" + e.Message);
         return(null);
     }
 }
Esempio n. 7
0
 private void AddInfo(string level, string info)
 {
     InfoLogger.SendInfo("AutoUpdate", level, info);
 }