示例#1
0
        public void  UpdateOneGroup(OneRoomGroup oneGroup, string roomId, int userCount)
        {
            var findedRoom = oneGroup.FindRoom(roomId);

            if (findedRoom == null)
            {
                throw new Exception($"somthing error cannot find room{roomId}");
            }

            //从匹配队列和空闲队列中出队列
            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(userCount);
            InsertNewInfo(oneGroup, findedRoom);
        }
示例#2
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);
            }
        }
示例#3
0
        public void JoinOneRoomFailed(string gameKey, string roomId)
        {
            OneRoomGroup oneGroup = null;

            if (!_roomGroups.TryGetValue(gameKey, out oneGroup))
            {
                return;
            }
            var room = oneGroup.FindRoom(roomId);

            if (room == null)
            {
                return;
            }
            UpdateOneGroup(oneGroup, room.RoomId, room.UserCount - 1);
        }
示例#4
0
        public bool JoinOneRoom(string gameKey, string roomId)
        {
            OneRoomGroup oneGroup = null;

            if (!_roomGroups.TryGetValue(gameKey, out oneGroup))
            {
                return(false);
            }
            var room = oneGroup.FindRoom(roomId);

            if (room == null)
            {
                return(false);
            }
            if (room.IsFull())
            {
                return(false);
            }
            UpdateOneGroup(oneGroup, room.RoomId, room.UserCount + 1);
            return(true);
        }