Exemple #1
0
        public void SyncRoom(OneRoomGroup oneGroup, RoomInfo newRoomInfo)
        {
            var findedRoom = oneGroup.FindRoom(newRoomInfo.RoomId);

            if (findedRoom == null)
            {
                findedRoom = newRoomInfo;
                oneGroup.CreatRoom(findedRoom);
                _allRoomId.Add(newRoomInfo.RoomId);
                if (findedRoom.IsEmpty())
                {
                    oneGroup.AddEmptyRoom(findedRoom);
                }
                else if (findedRoom.IsFull())
                {
                }
                else
                {
                    if (_matchingQueue.TryGetValue(findedRoom.Blind, out var sset))
                    {
                        sset.Add(findedRoom);
                    }
                    else
                    {
                        _matchingQueue.Add(findedRoom.Blind, new SortedSet <RoomInfo>()
                        {
                            findedRoom
                        });
                    }
                }
            }

            else
            {
                //从匹配队列和空闲队列中出队列
                if (findedRoom.IsEmpty())
                {
                    oneGroup.RemoveEmptyRoom(findedRoom.Blind, findedRoom.RoomId);
                }
                else if (findedRoom.IsFull())
                {
                }
                else
                {
                    _matchingQueue.TryGetValue(findedRoom.Blind, out var sset);
                    if (sset != null)
                    {
                        sset.Remove(findedRoom);
                    }
                }
                findedRoom.UpdateUserCount(newRoomInfo.UserCount);
                InsertNewInfo(oneGroup, findedRoom);
            }
        }
Exemple #2
0
 public void InsertNewInfo(OneRoomGroup oneGroup, RoomInfo info)
 {
     if (info.IsEmpty())
     {
         oneGroup.AddEmptyRoom(info);
     }
     else if (info.IsFull())
     {
     }
     else
     {
         if (_matchingQueue.TryGetValue(info.Blind, out var sset))
         {
             sset.Add(info);
         }
         else
         {
             _matchingQueue.Add(info.Blind, new SortedSet <RoomInfo>()
             {
                 info
             });
         }
     }
 }