Exemplo n.º 1
0
        public static async Task <string> Getkd(string kd, int rommId, string devid, long timeStamp)
        {
            object[] obj = new object[4];
            obj[0] = hex2bin(kd);
            obj[1] = rommId;
            obj[2] = devid;
            obj[3] = timeStamp;
            long[] longs = await JSImplement.GetJSImplement(rommId).Getkd(obj);

            return(hex(longs));
        }
Exemplo n.º 2
0
 /// <summary>
 /// 添加监控房间
 /// </summary>
 /// <param name="ROOM_ID"></param>
 /// <param name="IsMonitorRoom"></param>
 /// <returns></returns>
 public async void AddMonitor(int ROOM_ID, bool IsMonitorRoom = true)
 {
     await Task.Run(async() =>
     {
         if (!douyuRooms.ContainsKey(ROOM_ID))
         {
             //获取礼物
             await DouyuRoom.GetLiwu(ROOM_ID);
             if (JSImplement.GetJSImplement(ROOM_ID) == null)
             {
                 new JSImplement(ROOM_ID);
             }
             douyuRooms[ROOM_ID] = new List <DouyuRoom>();
         }
         var room = new DouyuRoom(ROOM_ID, IsMonitorRoom);
         //事件绑定
         room.BarrageNotice   = BarrageNotice;
         room.GiftNotice      = GiftNotice;
         room.DouyuRoomError += (DouyuRoom obj) =>
         {
             douyuRooms[obj.ROOM_ID].Remove(obj);
             Console.WriteLine($"【房间:{obj.ROOM_ID}】人数{douyuRooms[obj.ROOM_ID].Count}");
             OnConnectResult?.Invoke(room.ROOM_ID, false);
         };
         Console.WriteLine($"初始化房间:{ROOM_ID}");
         bool flag = await ConnectRoomAsync(room);
         //如果成功连接
         if (flag)
         {
             douyuRooms[ROOM_ID].Add(room);
             //房间连接成功通知
             OnConnectResult?.Invoke(room.ROOM_ID, true);
         }
         else
         {
             //房间连接失败通知
             OnConnectResult?.Invoke(room.ROOM_ID, false);
             room.Dispose();
         }
     });
 }