//-------------------------------------------------------------------------------------------------------------------------- //供外部通过DispatchAction调用的方法,会在不同线程执行,需要保证多线程安全。 //-------------------------------------------------------------------------------------------------------------------------- internal void RequestEnterScene(Msg_LB_RequestEnterScene msg) { //添加/更新玩家数据 UserInfo info = AddOrUpdateUserInfo(msg.BaseInfo, msg.User, UserInfo.c_LifeTimeWaitStartGame); //开始进野外流程 RoomProcessThread roomProcess = LobbyServer.Instance.RoomProcessThread; roomProcess.QueueAction(roomProcess.RequestEnterScene, info.Guid, msg.SceneId, msg.WantRoomId, msg.FromSceneId); }
private void HandleRequestSceneRoomList(NodeMessage msg, int handle, uint seq) { GameFrameworkMessage.NodeMessageWithGuid headerMsg = msg.m_NodeHeader as GameFrameworkMessage.NodeMessageWithGuid; if (null != headerMsg) { ulong guid = headerMsg.m_Guid; RoomProcessThread roomProcess = LobbyServer.Instance.RoomProcessThread; roomProcess.QueueAction(roomProcess.RequestSceneRoomList, guid); } }
internal bool StartDare(DareInfo info) { if (null == info) { return(false); } List <ulong> guidList = new List <ulong>(); guidList.Add(info.offense); guidList.Add(info.defence); RoomProcessThread roomProcess = LobbyServer.Instance.RoomProcessThread; roomProcess.QueueAction(roomProcess.AllocLobbyRoom, guidList.ToArray(), (int)MatchSceneEnum.Dare); return(true); }
//-------------------------------------------------------------------------------------------------------------------------- //后面的方法都是在内部线程执行的方法,不涉及多线程操作,不用加锁,串行执行。 //-------------------------------------------------------------------------------------------------------------------------- private void OnTick() { long curTime = TimeUtility.GetLocalMilliseconds(); int elapsedTickTime = m_Thread.TickSleepTime; if (m_LastTickTime > 0) { elapsedTickTime = (int)(curTime - m_LastTickTime); if (elapsedTickTime < 0) { elapsedTickTime = m_Thread.TickSleepTime; } } m_LastTickTime = curTime; if (m_LastLogTime + 60000 < curTime) { m_LastLogTime = curTime; DebugPoolCount((string msg) => { LogSys.Log(LOG_TYPE.INFO, "UserProcessScheduler.DispatchActionQueue {0}", msg); }); DebugActionCount((string msg) => { LogSys.Log(LOG_TYPE.MONITOR, "UserProcessScheduler.DispatchActionQueue {0}", msg); }); m_Thread.DebugPoolCount((string msg) => { LogSys.Log(LOG_TYPE.INFO, "UserProcessScheduler.ThreadActionQueue {0}", msg); }); LogSys.Log(LOG_TYPE.MONITOR, "UserProcessScheduler.ThreadActionQueue Current Action {0}", m_Thread.CurActionNum); m_NodeMessageManager.TickMonitor(); LogSys.Log(LOG_TYPE.MONITOR, "Lobby User Count:{0} ElapsedTickTime:{1}", m_ActiveUserGuids.Count, elapsedTickTime); } m_DeactiveUserGuids.Clear(); foreach (var guidPair in m_ActiveUserGuids) { ulong guid = guidPair.Key; UserInfo user = GetUserInfo(guid); if (user == null) { m_DeactiveUserGuids.Add(guid); } else { user.LeftLife -= elapsedTickTime; if (user.LeftLife <= 0) { if (UserState.Room != user.CurrentState) { if (user.Room != null) { RoomProcessThread roomProcess = LobbyServer.Instance.RoomProcessThread; roomProcess.QueueAction(roomProcess.QuitRoom, guid, true, 0); } m_DeactiveUserGuids.Add(guid); } else { user.LeftLife = UserInfo.c_NextLifeTime; } } } } int tmpValue = 0; foreach (ulong guid in m_DeactiveUserGuids) { m_ActiveUserGuids.TryRemove(guid, out tmpValue); AddWaitRecycleUser(guid); } m_DeactiveUserGuids.Clear(); foreach (ulong guid in m_WaitRecycleUsers) { UserInfo user = GetUserInfo(guid); if (user == null) { m_DeactiveUserGuids.Add(guid); } else { FreeKey(user.Key); ulong g = 0; m_GuidByNickname.TryRemove(user.Nickname, out g); UserInfo tmp; m_UserInfos.TryRemove(guid, out tmp); RecycleUserInfo(user); m_DeactiveUserGuids.Add(guid); } } foreach (ulong guid in m_DeactiveUserGuids) { m_WaitRecycleUsers.Remove(guid); } }