Пример #1
0
        /// <summary>
        /// Метод, подключающий клиента к комнате
        /// </summary>
        /// <param name="roomChannel"></param>
        public void AttachToRoom(IRoomChannel roomChannel)
        {
            if (roomChannel != null)
            {
                Log.Info("Attach client " + ClientId + " to RoomId: " + roomChannel.RoomId);
            }
            else
            {
                Log.Info("Detach client " + ClientId + "to Room " + Room + "...");
            }

            Room        = roomChannel?.RoomId;
            RoomChannel = roomChannel;
        }
Пример #2
0
        /// <summary>
        /// ћетод, удал¤ет комнату по еЄ идентификатору
        /// </summary>
        /// <param name="roomChannel"></param>
        /// <param name="reason"></param>
        public void FreeRoom(IRoomChannel roomChannel, RoomRemoveReason reason)
        {
            bool successRemove;

            lock (_channels)
                successRemove = _channels.Remove(roomChannel.RoomId);

            //провер¤ем, что комната уже удалена
            if (successRemove)
            {
                _log.Info("Free roomId: " + roomChannel.RoomId + " reason: " + reason);
                foreach (var roomChannelClient in roomChannel.Clients)
                {
                    roomChannelClient.Detach();
                }

                _poolChannels.Free(roomChannel);
            }
        }