Beispiel #1
0
        private static async Task StartAsync(uint start, uint end)
        {
            uint[]   roomIds;
            int      count;
            TimeSpan interval;

            roomIds = await LiveApi.GetRoomIdsDynamicAsync(start, end);

            count    = (int)(end - start);
            interval = TimeSpan.FromMilliseconds(DanmuApi.HeartBeatInterval.TotalMilliseconds / count);
            for (uint i = start; i < end; i++)
            {
                DateTime     startTime;
                DanmuMonitor danmuMonitor;
                TimeSpan     span;

                startTime    = DateTime.Now;
                danmuMonitor = new DanmuMonitor(roomIds[i], (int)i, i == start);
                danmuMonitor.DanmuHandler += DanmuMonitor_DanmuHandler;
                danmuMonitor.Execute();
                span = interval - (DateTime.Now - startTime);
                if (span.Ticks > 0)
                {
                    await Task.Delay(span);
                }
            }
        }
Beispiel #2
0
        private static void Main(string[] args)
        {
            Console.Title         = GetTitle();
            GlobalSettings.Logger = Logger.Instance;
            if (!BitConverter.IsLittleEndian)
            {
                GlobalSettings.Logger.LogWarning("在BigEndian模式的CPU下工作可能导致程序出错");
                GlobalSettings.Logger.LogWarning("如果出现错误,请创建issue");
                //throw new PlatformNotSupportedException();
            }
            try {
                GlobalSettings.LoadAll();
            }
            catch (Exception ex) {
                GlobalSettings.Logger.LogException(ex);
                GlobalSettings.Logger.LogError("缺失或无效配置文件");
                Console.ReadKey(true);
                return;
            }
            DanmuMonitor danmuMonitor = new DanmuMonitor(new uint[] { 4816623 } /*LiveApi.GetRoomIdsDynamic(0, 1000).GetAwaiter().GetResult()*/);

            danmuMonitor.Start();
            //TcpClient[] clients = DanmuApi.CreateClients(LiveApi.GetRoomIdsDynamic(0, 5).GetAwaiter().GetResult());
            //client.Connect()
            //DanmuApi.EnterRoom(client, 10209381);

            //var result = LiveApi.GetRoomIdsDynamic(0, 1).GetAwaiter().GetResult();
            Console.ReadKey(true);
        }