ע��������internal��������Ӧ���ǿ��̵߳����Ƿ�ȫ������
Inheritance: MyServerThread
Exemple #1
0
        private void HandleUserQuit(Msg_LR_UserQuit msg, PBChannel channel, int handle, uint seq)
        {
            bool isFieldThread;
            int  ix = GetActiveRoomThreadIndex(msg.RoomID, out isFieldThread);

            if (ix >= 0)
            {
                if (isFieldThread)
                {
                    RoomThread roomThread = field_roomthread_list_[ix];
                    roomThread.QueueAction(roomThread.HandleUserQuit, msg, channel);
                }
                else
                {
                    RoomThread roomThread = roomthread_list_[ix];
                    roomThread.QueueAction(roomThread.HandleUserQuit, msg, channel);
                }
            }
            else
            {
                Msg_RL_UserQuit replyBuilder = new Msg_RL_UserQuit();
                replyBuilder.UserGuid = msg.UserGuid;
                replyBuilder.RoomID   = msg.RoomID;
                channel.Send(replyBuilder);
            }
        }
Exemple #2
0
        private void HandleReconnectUser(Msg_LR_ReconnectUser urMsg, PBChannel channel, int handle, uint seq)
        {
            bool isFieldThread;
            int  ix = GetActiveRoomThreadIndex(urMsg.RoomID, out isFieldThread);

            if (ix < 0)
            {
                Msg_RL_ReplyReconnectUser replyBuilder = new Msg_RL_ReplyReconnectUser();
                replyBuilder.UserGuid = urMsg.UserGuid;
                replyBuilder.RoomID   = urMsg.RoomID;
                replyBuilder.Result   = (int)Msg_RL_ReplyReconnectUser.ReconnectResultEnum.NotExist;
                channel.Send(replyBuilder);
            }
            else
            {
                if (isFieldThread)
                {
                    RoomThread roomThread = field_roomthread_list_[ix];
                    roomThread.QueueAction(roomThread.HandleReconnectUser, urMsg, channel, handle, seq);
                }
                else
                {
                    RoomThread roomThread = roomthread_list_[ix];
                    roomThread.QueueAction(roomThread.HandleReconnectUser, urMsg, channel, handle, seq);
                }
            }
        }
Exemple #3
0
        private void HandleActiveScene(Msg_LR_ActiveScene msg, PBChannel channel, int handle, uint seq)
        {
            int          roomid    = msg.RoomID;
            int          sceneId   = msg.SceneID;
            List <ulong> users     = msg.UserGuids;
            int          thread_id = GetIdleThread();

            if (thread_id < 0)
            {
                LogSys.Log(LOG_TYPE.ERROR, "all room are using, active room failed!");
                Msg_RL_ActiveSceneResult retMsg = new Msg_RL_ActiveSceneResult();
                retMsg.UserGuids.AddRange(users);
                retMsg.RoomID = roomid;
                retMsg.Result = (int)SceneOperationResultEnum.Cant_Find_Room;
                return;
            }
            RoomThread roomThread = roomthread_list_[thread_id];

            AddActiveRoom(roomid, thread_id, false);
            roomThread.PreActiveRoom();
            LogSys.Log(LOG_TYPE.INFO, "queue active room {0} scene {1} thread {2}", roomid, sceneId, thread_id);
            roomThread.QueueAction(roomThread.ActiveRoom, roomid, sceneId, (MyAction <bool>)((bool val) => {
                Msg_RL_ActiveSceneResult retMsg = new Msg_RL_ActiveSceneResult();
                retMsg.UserGuids.AddRange(users);
                retMsg.RoomID = roomid;
                retMsg.Result = val ? (int)SceneOperationResultEnum.Success : (int)SceneOperationResultEnum.Cant_Find_Room;
            }));
        }
Exemple #4
0
 internal RoomManager(uint maxusernum, uint thread_amount, uint room_amount)
 {
     thread_amount_        = thread_amount;
     room_amount_          = room_amount;
     roomthread_list_      = new RoomThread[thread_amount];
     user_pool_size_       = maxusernum;
     user_pool_            = new UserPool();
     thread_tick_interval_ = 50;
 }
Exemple #5
0
 internal RoomManager(uint maxusernum, uint thread_amount, uint room_amount, uint tick_interval, Connector conn)
 {
     thread_amount_        = thread_amount;
     room_amount_          = room_amount;
     roomthread_list_      = new RoomThread[thread_amount];
     user_pool_size_       = maxusernum;
     user_pool_            = new UserPool();
     dispatcher_           = new Dispatcher();
     thread_tick_interval_ = tick_interval;
     connector_            = conn;
 }
        public RoomManager(uint maxusernum, uint thread_amount, uint room_amount)
        {
            s_Instance = this;

            m_ThreadAmount       = thread_amount;
            m_RoomAmount         = room_amount;
            m_RoomThreadList     = new RoomThread[thread_amount];
            m_UserPoolSize       = maxusernum;
            m_UserPool           = new UserPool();
            m_ThreadTickInterval = 50;
        }
Exemple #7
0
        internal void ChangeRoomScene(int roomid, int sceneId)
        {
            bool isFieldThread;
            int  ix = GetActiveRoomThreadIndex(roomid, out isFieldThread);

            if (ix >= 0 && !isFieldThread)
            {
                RoomThread thread = roomthread_list_[ix];
                thread.QueueAction(thread.ChangeRoomScene, roomid, sceneId, (MyAction <bool>)((bool success) => {
                }));
            }
        }
Exemple #8
0
        internal bool Init(string roomServerName)
        {
            lock_obj_     = new object();
            active_rooms_ = new Dictionary <int, int>();
            user_pool_.Init(user_pool_size_);

            // 初始化场景房间
            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.Room)
                {
                    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(thread_tick_interval_, (uint)cfg.RoomCountPerThread, user_pool_, connector_);
                                for (int rix = 0; rix < cfg.RoomCountPerThread; ++rix)
                                {
                                    fieldThread.ActiveFieldRoom(startId, cfg.id);
                                    AddActiveRoom(startId, field_roomthread_list_.Count, true);
                                    AddFieldSceneRoomId(cfg.id, startId);
                                    ++startId;
                                }
                                field_roomthread_list_.Add(fieldThread);
                            }
                            else
                            {
                                for (int rix = 0; rix < cfg.RoomCountPerThread; ++rix)
                                {
                                    ++startId;
                                }
                            }
                        }
                    }
                }
            }
            // 初始化房间线程
            for (int i = 0; i < thread_amount_; ++i)
            {
                roomthread_list_[i] = new RoomThread(this);
                roomthread_list_[i].Init(thread_tick_interval_, room_amount_, user_pool_, connector_);
            }
            next_room_id_ = startId;
            return(true);
        }
        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);
        }
        public RoomManager(uint maxusernum, uint thread_amount, uint room_amount, uint tick_interval, Connector conn)
        {
            s_Instance = this;

            m_ThreadAmount       = thread_amount;
            m_RoomAmount         = room_amount;
            m_RoomThreadList     = new RoomThread[thread_amount];
            m_UserPoolSize       = maxusernum;
            m_UserPool           = new UserPool();
            m_Dispatcher         = new Dispatcher();
            m_ThreadTickInterval = tick_interval;
            m_Connector          = conn;
        }
Exemple #11
0
        private void HandleRoomStoryMessage(Msg_LRL_StoryMessage msg, PBChannel channel, int handle, uint seq)
        {
            bool isFieldRoom;
            int  ix = GetActiveRoomThreadIndex(msg.RoomId, out isFieldRoom);

            if (ix >= 0)
            {
                if (isFieldRoom)
                {
                    RoomThread roomThread = field_roomthread_list_[ix];
                    roomThread.QueueAction(roomThread.HandleRoomStoryMessage, msg, channel);
                }
                else
                {
                    RoomThread roomThread = roomthread_list_[ix];
                    roomThread.QueueAction(roomThread.HandleRoomStoryMessage, msg, channel);
                }
            }
        }
Exemple #12
0
        private void HandleReclaimItem(Msg_LR_ReclaimItem msg, PBChannel channel, int handle, uint seq)
        {
            bool isFieldThread;
            int  ix = GetActiveRoomThreadIndex(msg.RoomID, out isFieldThread);

            if (ix >= 0)
            {
                if (isFieldThread)
                {
                    RoomThread roomThread = field_roomthread_list_[ix];
                    roomThread.QueueAction(roomThread.HandleReclaimItem, msg, channel);
                }
                else
                {
                    RoomThread roomThread = roomthread_list_[ix];
                    roomThread.QueueAction(roomThread.HandleReclaimItem, msg, channel);
                }
            }
        }
Exemple #13
0
        private void HandleUserRelive(Msg_LR_UserReLive msg, PBChannel channel, int handle, uint seq)
        {
            bool isFieldThread;
            int  ix = GetActiveRoomThreadIndex(msg.RoomID, out isFieldThread);

            if (ix >= 0)
            {
                if (isFieldThread)
                {
                    RoomThread roomThread = field_roomthread_list_[ix];
                    roomThread.QueueAction(roomThread.HandleUserRelive, msg);
                }
                else
                {
                    RoomThread roomThread = roomthread_list_[ix];
                    roomThread.QueueAction(roomThread.HandleUserRelive, msg);
                }
            }
        }
        internal bool Init(string roomServerName)
        {
            lock_obj_ = new object();
            active_rooms_ = new Dictionary<int, int>();
            user_pool_.Init(user_pool_size_);

            // ��ʼ����������
            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.Room) {
                    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(thread_tick_interval_, (uint)cfg.RoomCountPerThread, user_pool_, connector_);
                                for (int rix = 0; rix < cfg.RoomCountPerThread; ++rix) {
                                    fieldThread.ActiveFieldRoom(startId, cfg.id);
                                    AddActiveRoom(startId, field_roomthread_list_.Count, true);
                                    AddFieldSceneRoomId(cfg.id, startId);
                                    ++startId;
                                }
                                field_roomthread_list_.Add(fieldThread);
                            } else {
                                for (int rix = 0; rix < cfg.RoomCountPerThread; ++rix) {
                                    ++startId;
                                }
                            }
                        }
                    }
                }
            }
            // ��ʼ�������߳�
            for (int i = 0; i < thread_amount_; ++i) {
                roomthread_list_[i] = new RoomThread(this);
                roomthread_list_[i].Init(thread_tick_interval_, room_amount_, user_pool_, connector_);
            }
            next_room_id_ = startId;
            return true;
        }