GameFramework.RoomThread.ActiveFieldRoom C# (CSharp) Method

ActiveFieldRoom() private method

private ActiveFieldRoom ( int roomid, int sceneId ) : void
roomid int
sceneId int
return void
        internal void ActiveFieldRoom(int roomid, int sceneId)
        {
            LogSys.Log(LOG_TYPE.INFO, "[0] active field room {0} scene {1} thread {2}", roomid, sceneId, cur_thread_id_);
            Room rm = room_pool_.NewRoom();
            if (null == rm) {
                Interlocked.Decrement(ref preactive_room_count_);

                LogSys.Log(LOG_TYPE.ERROR, "Failed active field room {0} in thread {1}, preactive room count {2}",
                    roomid, cur_thread_id_, preactive_room_count_);
                return;
            }
            LogSys.Log(LOG_TYPE.INFO, "[1] active field room {0} scene {1} thread {2}", roomid, sceneId, cur_thread_id_);
            rm.ScenePool = scene_pool_;
            rm.Init(roomid, sceneId, user_pool_, connector_);
            LogSys.Log(LOG_TYPE.INFO, "[2] active field room {0} scene {1} thread {2}", roomid, sceneId, cur_thread_id_);

            rm.IsFieldRoom = true;

            LogSys.Log(LOG_TYPE.INFO, "[3] active field room {0} scene {1} thread {2}", roomid, sceneId, cur_thread_id_);

            //����ȫ����ɺ��ټӵ�������б����ʼtick
            active_room_.Add(rm);
            Interlocked.Decrement(ref preactive_room_count_);

            LogSys.Log(LOG_TYPE.DEBUG, "active field room {0} in thread {1}, preactive room count {2}",
                roomid, cur_thread_id_, preactive_room_count_);
        }

Usage Example

        public bool Init(string roomServerName)
        {
            m_Lock        = new object();
            m_ActiveRooms = new Dictionary <int, int>();
            m_UserPool.Init(m_UserPoolSize);

            // 初始化场景房间
            int startId = 1;
            MyDictionary <int, object> scenes = TableConfig.LevelProvider.Instance.LevelMgr.GetData();

            foreach (KeyValuePair <int, object> pair in scenes)
            {
                TableConfig.Level cfg = pair.Value as TableConfig.Level;
                if (null != cfg && cfg.type == (int)SceneTypeEnum.Story)
                {
                    foreach (string roomSvrName in cfg.RoomServer)
                    {
                        for (int ix = 0; ix < cfg.ThreadCountPerScene; ++ix)
                        {
                            if (0 == roomServerName.CompareTo(roomSvrName))
                            {
                                RoomThread fieldThread = new RoomThread(this);
                                fieldThread.Init(m_ThreadTickInterval, (uint)cfg.RoomCountPerThread, m_UserPool, m_Connector);
                                for (int rix = 0; rix < cfg.RoomCountPerThread; ++rix)
                                {
                                    fieldThread.ActiveFieldRoom(startId, cfg.id);
                                    AddActiveRoom(startId, m_FieldRoomthreadList.Count, true);
                                    AddFieldSceneRoomId(cfg.id, startId);
                                    ++startId;
                                }
                                m_FieldRoomthreadList.Add(fieldThread);
                            }
                            else
                            {
                                for (int rix = 0; rix < cfg.RoomCountPerThread; ++rix)
                                {
                                    ++startId;
                                }
                            }
                        }
                    }
                }
            }
            // 初始化房间线程
            for (int i = 0; i < m_ThreadAmount; ++i)
            {
                m_RoomThreadList[i] = new RoomThread(this);
                m_RoomThreadList[i].Init(m_ThreadTickInterval, m_RoomAmount, m_UserPool, m_Connector);
            }
            m_NextRoomId = startId;
            return(true);
        }
All Usage Examples Of GameFramework.RoomThread::ActiveFieldRoom