Log() public static method

public static Log ( LOG_TYPE logtype, ConsoleColor, cc, string format ) : void
logtype LOG_TYPE
cc ConsoleColor,
format string
return void
示例#1
0
        //响应RoomServer玩家重新连接进入房间的反馈消息
        internal void OnReplyReconnectUser(ulong userGuid, int roomID, int result)
        {
            UserInfo user = LobbyServer.Instance.UserProcessScheduler.GetUserInfo(userGuid);

            if (user == null)
            {
                return;
            }
            switch (result)
            {
            case (int)Msg_RL_ReplyReconnectUser.ReconnectResultEnum.Drop: {
                user.CurrentState = UserState.Room;
                RoomInfo room = m_LobbyInfo.GetRoomByID(roomID);
                if (null != room)
                {
                    RoomServerInfo svrInfo;
                    if (m_LobbyInfo.RoomServerInfos.TryGetValue(room.RoomServerName, out svrInfo))
                    {
                        if (null != svrInfo)
                        {
                            NodeMessage startGameResultMsg = new NodeMessage(LobbyMessageDefine.EnterSceneResult, user.Guid);
                            GameFrameworkMessage.EnterSceneResult protoData = new GameFrameworkMessage.EnterSceneResult();
                            protoData.server_ip   = svrInfo.ServerIp;
                            protoData.server_port = svrInfo.ServerPort;
                            protoData.key         = user.Key;
                            protoData.camp_id     = user.CampId;
                            protoData.scene_type  = room.SceneType;
                            protoData.result      = (int)GeneralOperationResult.LC_Succeed;
                            protoData.prime       = Helper.Random.Next(2, 21);

                            startGameResultMsg.m_ProtoData = protoData;
                            LobbyServer.Instance.TransmitToWorld(user, startGameResultMsg);
                            //重新进入房间成功
                            LogSys.Log(LOG_TYPE.INFO, "user reconnected roomServer success, guid {0}", userGuid);
                        }
                    }
                }
            }
            break;

            case (int)Msg_RL_ReplyReconnectUser.ReconnectResultEnum.NotExist: {
                //不存在,执行进场景流程
                RequestEnterScene(userGuid, user.SceneId, roomID, 0);
                LogSys.Log(LOG_TYPE.INFO, "user reconnected roomserver, not exist, request enter scene ! guid {0}", userGuid);
            }
            break;

            case (int)Msg_RL_ReplyReconnectUser.ReconnectResultEnum.Online: {
                NodeMessage startGameResultMsg = new NodeMessage(LobbyMessageDefine.EnterSceneResult, user.Guid);
                GameFrameworkMessage.EnterSceneResult protoData = new GameFrameworkMessage.EnterSceneResult();
                protoData.result = (int)GeneralOperationResult.LC_Failed;

                startGameResultMsg.m_ProtoData = protoData;
                LobbyServer.Instance.TransmitToWorld(user, startGameResultMsg);
                //room上玩家还是连接与在线状态,重连失败
                LogSys.Log(LOG_TYPE.INFO, "user reconnected roomserver, user already online, guid {0}", userGuid);
            }
            break;
            }
        }
示例#2
0
 internal void Init(PBChannel channel)
 {
     channel_ = channel;
     channel_.Register <LNReq_Connect>(ConnectHandler);
     channel_.Register <LNReq_Load>(LoadHandler);
     LogSys.Log(LOG_TYPE.INFO, "DataScheduler initialized");
 }
示例#3
0
 internal static void KeepConnection()
 {
     if (m_MySqlConn == null)
     {
         LogSys.Log(LOG_TYPE.INFO, "MySql Connection :{0}", DataCacheConfig.MySqlConnectString);
         try {
             m_MySqlConn = new MySqlConnection(DataCacheConfig.MySqlConnectString);
             m_MySqlConn.Open();
         } catch (System.Exception ex) {
             m_MySqlConn = null;
             LogSys.Log(LOG_TYPE.ERROR, "MySql Connection ERROR :{0}", ex);
         }
     }
     else
     {
         try {
             if (m_MySqlConn != null && m_MySqlConn.State == System.Data.ConnectionState.Closed)
             {
                 m_MySqlConn.Open();
                 LogSys.Log(LOG_TYPE.INFO, "MySql connection open again...", DataCacheConfig.MySqlConnectString);
             }
         } catch (System.Exception ex) {
             m_MySqlConn = null;
             LogSys.Log(LOG_TYPE.ERROR, "MySql Connection ERROR :{0}", ex);
         }
     }
 }
示例#4
0
        private void OnCommand(int src, int dest, string command)
        {
            const string c_QuitLobby    = "QuitLobby";
            const string c_ReloadConfig = "ReloadConfig";

            try {
                if (0 == command.CompareTo(c_QuitLobby))
                {
                    LogSys.Log(LOG_TYPE.MONITOR, "receive {0} command, save data and then quitting ...", command);
                    if (!m_WaitQuit)
                    {
                        m_UserProcessScheduler.DispatchAction(m_UserProcessScheduler.DoCloseServers);
                        m_LastWaitQuitTime = TimeUtility.GetLocalMilliseconds();
                        m_WaitQuit         = true;
                    }
                }
                else if (0 == command.CompareTo(c_ReloadConfig))
                {
                    CenterClientApi.ReloadConfigScript();
                    LobbyConfig.Init();
                    LogSys.Log(LOG_TYPE.WARN, "receive {0} command.", command);
                }
            } catch (Exception ex) {
                LogSys.Log(LOG_TYPE.ERROR, "Exception {0}\n{1}", ex.Message, ex.StackTrace);
            }
        }
示例#5
0
        public void ChangeScene(int scene_type)
        {
            m_RoomUserMgr.ActiveScene.Reset();
            m_ScenePool.RecycleScene(m_RoomUserMgr.ActiveScene);
            m_RoomUserMgr.ActiveScene = null;

            foreach (User us in m_RoomUserMgr.RoomUsers)
            {
                us.IsEntered = false;
            }

            m_CanCloseTime            = 0;
            m_RoomUserMgr.ActiveScene = m_ScenePool.NewScene();
            m_RoomUserMgr.ActiveScene.SetRoomUserManager(m_RoomUserMgr);
            //场景数据加载由加载线程执行(注:场景没有加载完成,场景状态仍然是sleep,Scene.Tick不会有实际的动作)
            SceneLoadThread.Instance.QueueAction(m_RoomUserMgr.ActiveScene.LoadData, scene_type);

            OnChangeScene();

            Msg_RC_ChangeScene msg = new Msg_RC_ChangeScene();

            msg.target_scene_id = scene_type;
            foreach (User us in m_RoomUserMgr.RoomUsers)
            {
                us.SendMessage(RoomMessageDefine.Msg_RC_ChangeScene, msg);
            }

            LogSys.Log(LOG_TYPE.INFO, "Room.ChangeScene {0} scene {1}", m_RoomId, scene_type);
        }
示例#6
0
        internal static void Execute(object msg, User user)
        {
            Msg_CR_UserMoveToPos move_msg = msg as Msg_CR_UserMoveToPos;

            if (move_msg == null)
            {
                return;
            }
            UserInfo charactor = user.Info;

            if (charactor == null)
            {
                LogSys.Log(LOG_TYPE.ERROR, "charactor {0} not exist", user.RoleId);
                return;
            }
            ///
            if (charactor.GetAIEnable())
            {
                MovementStateInfo msi = charactor.GetMovementStateInfo();
                msi.PositionX = move_msg.cur_pos_x;
                msi.PositionZ = move_msg.cur_pos_z;

                UserAiStateInfo asi = charactor.GetAiStateInfo();
                Vector3         pos = new Vector3(move_msg.target_pos_x, 0, move_msg.target_pos_z);
                asi.TargetPos          = pos;
                asi.IsTargetPosChanged = true;
                asi.ChangeToState((int)(AiStateId.Move));
            }
        }
    //向DB中写入多条数据
    internal static int BatchSaveItemsSql(int msgId, List <InnerCacheItem> cacheItemList, int dataVersion)
    {
        int count = 0;

        if (DataCacheConfig.IsPersistent)
        {
            try {
                List <bool>   validList = new List <bool>();
                List <byte[]> dataList  = new List <byte[]>();
                foreach (var cacheItem in cacheItemList)
                {
                    validList.Add(cacheItem.Valid);
                    dataList.Add(cacheItem.DataMessage);
                }
                count = DataDML.BatchSave(msgId, validList, dataList, dataVersion);
                LogSys.Log(LOG_TYPE.MONITOR, "BatchSaveItemsSql SUCCESS. MsgId:{0}, DataCount:{1}, DataVersion:{2}", msgId, cacheItemList.Count, dataVersion);
            } catch (Exception ex) {
                DBConn.Close();
                LogSys.Log(LOG_TYPE.ERROR, "BatchSaveItemsSql ERROR. MsgId:{0}, Error:{1}\nStacktrace:{2}", msgId, ex.Message, ex.StackTrace);
                throw ex;
            }
        }
        else
        {
            count = cacheItemList.Count;
        }
        return(count);
    }
示例#8
0
        internal void HandleClientMsg(object msg, User user)
        {
            if (msg == null)
            {
                LogSys.Log(LOG_TYPE.ERROR, "{0}", "can't handle null msg");
                return;
            }
            Type             msg_type = msg.GetType();
            ClientMsgHandler handler;

            if (!client_msg_handlers_.TryGetValue(msg_type, out handler))
            {
                if (client_default_handler_ != null)
                {
                    client_default_handler_(msg, user);
                }
                else
                {
                    LogSys.Log(LOG_TYPE.ERROR, "{0}", "message no deal&default handler!");
                }
                return;
            }
            if (handler != null)
            {
                handler(msg, user);
            }
        }
示例#9
0
 public Authentication(string passwd, string ip, string mac_addr)
 {
     passwd_   = passwd;
     ip_       = ip;
     mac_addr_ = mac_addr;
     LogSys.Log(LOG_TYPE.DEBUG, ConsoleColor.Cyan, "Account {0} login state: {1}", Account, GetType().Name);
 }
        private void HandleBattleEnd(Msg_RL_BattleEnd msg, PBChannel channel, int src, uint session)
        {
            int roomID = msg.RoomID;

            LogSys.Log(LOG_TYPE.DEBUG, "Battle Info: RoomID = {0}", roomID);
            m_RoomProcessThread.QueueAction(m_RoomProcessThread.OnRoomBattleEnd, msg);
        }
示例#11
0
 internal void SaveMail(List <TableMailInfoWrap> mailList, int saveCount)
 {
     try {
         foreach (var mailInfo in mailList)
         {
             if (!mailInfo.Modified)
             {
                 continue;
             }
             TableMailInfo dataMail = mailInfo.ToProto();
             List <int>    itemIds  = new List <int>();
             List <int>    itemNums = new List <int>();
             foreach (var item in mailInfo.m_Items)
             {
                 itemIds.Add(item.m_ItemId);
                 itemNums.Add(item.m_ItemNum);
             }
             dataMail.ItemIds     = Converter.IntList2String(itemIds);
             dataMail.ItemNumbers = Converter.IntList2String(itemNums);
             Msg_LD_Save msg = new Msg_LD_Save();
             msg.MsgId = (int)DataEnum.TableMailInfo;
             msg.PrimaryKeys.Add(dataMail.Guid.ToString());
             msg.Data = DbDataSerializer.Encode(dataMail);
             DispatchAction(SaveInternal, msg);
         }
     } catch (Exception e) {
         LogSys.Log(LOG_TYPE.ERROR, "DataCache Save ERROR:{0}, Stacktrace:{1}", e.Message, e.StackTrace);
     }
 }
示例#12
0
        protected override void OnTick()
        {
            long curTime = TimeUtility.GetLocalMilliseconds();

            if (m_LastTickTime != 0)
            {
                long elapsedTickTime = curTime - m_LastTickTime;
                if (elapsedTickTime > c_WarningTickTime)
                {
                    LogSys.Log(LOG_TYPE.MONITOR, "GlobalProcessThread Tick:{0}", elapsedTickTime);
                }
            }
            m_LastTickTime = curTime;
            if (m_LastLogTime + 60000 < curTime)
            {
                m_LastLogTime = curTime;

                DebugPoolCount((string msg) => {
                    LogSys.Log(LOG_TYPE.INFO, "GlobalProcessThread.ActionQueue {0}", msg);
                });
                LogSys.Log(LOG_TYPE.MONITOR, "GlobalProcessThread.ActionQueue Current Action {0}", this.CurActionNum);
            }
            //逻辑Tick
            GlobalData.Instance.Tick();
            UserServer.Instance.UserProcessScheduler.NicknameSystem.Tick();
            m_MailSystem.Tick();
            //全局数据存储
            long saveStartTime = 0;
            var  dsThread      = UserServer.Instance.DataCacheThread;

            if (dsThread.DataStoreAvailable)
            {
                if (m_GuidCounter.IsTimeToSave(curTime))
                {
                    saveStartTime = TimeUtility.GetLocalMilliseconds();
                    dsThread.SaveGuid(m_GuidSystem.GuidList, m_GuidCounter.NextSaveCount);
                    LogSys.Log(LOG_TYPE.DEBUG, "GlobalDataSave Guid SaveCount:{0}, Time:{1}", m_GuidCounter.NextSaveCount, TimeUtility.GetLocalMilliseconds() - saveStartTime);
                    m_GuidCounter.IncreaseNextSaveCount();
                }
                if (m_MailCounter.IsTimeToSave(curTime))
                {
                    saveStartTime = TimeUtility.GetLocalMilliseconds();
                    dsThread.SaveMail(m_MailSystem.TotalMailList, m_MailCounter.NextSaveCount);
                    dsThread.SaveDeletedMail(m_MailSystem.TotalDeletedMailList, m_MailCounter.NextSaveCount);
                    m_MailSystem.ResetDeletedMailList();
                    LogSys.Log(LOG_TYPE.DEBUG, "GlobalDataSave Mail SaveCount:{0}, Time:{1}", m_MailCounter.NextSaveCount, TimeUtility.GetLocalMilliseconds() - saveStartTime);
                    m_MailCounter.IncreaseNextSaveCount();
                }
                if (m_IsLastSave && IsLastSaveAllDone())
                {
                    if (m_LastSaveFinished == false)
                    {
                        //全局数据(Guid、邮件)存储完成
                        LogSys.Log(LOG_TYPE.MONITOR, "DoLastSaveGlobalData Step_2: GlobalData last save done");
                        m_IsLastSave       = false;
                        m_LastSaveFinished = true;
                    }
                }
            }
        }
示例#13
0
        private void RequestEnterSceneRoom(UserInfo info, int roomId, int hp, int mp, float x, float y)
        {
            RoomInfo room = m_LobbyInfo.GetRoomByID(roomId);

            if (null != room)
            {
                int campId = (int)CampIdEnum.Blue;

                room.AddUsers(campId, info.Guid);
                Msg_LR_EnterScene enterSceneMsg = new Msg_LR_EnterScene();
                enterSceneMsg.UserGuid = info.Guid;
                enterSceneMsg.RoomId   = roomId;

                Msg_LR_RoomUserInfo ruiBuilder = info.RoomUserInfo;
                ruiBuilder.Key  = info.Key;
                ruiBuilder.Camp = info.CampId;
                if (hp > 0 && mp > 0)
                {
                    enterSceneMsg.HP = hp;
                    enterSceneMsg.MP = mp;
                }
                if (x > 0 && y > 0)
                {
                    ruiBuilder.EnterX = x;
                    ruiBuilder.EnterY = y;
                }
                enterSceneMsg.UserInfo = ruiBuilder;

                LobbyServer.Instance.RoomSvrChannel.Send(room.RoomServerName, enterSceneMsg);

                LogSys.Log(LOG_TYPE.DEBUG, "Request enter field, user {0} room {1}", info.Guid, roomId);
            }
        }
示例#14
0
        internal void OnRoomUserQuit(int roomid, ulong guid, Msg_RL_UserQuit originalMsg)
        {
            UserInfo user = LobbyServer.Instance.UserProcessScheduler.GetUserInfo(guid);

            if (user != null)
            {
                RoomInfo room = user.Room;
                if (null != room)
                {
                    if (room.RoomId == roomid)
                    {
                        room.DelUsers(guid);
                        user.ResetRoomInfo();
                        user.CurrentRoomID = 0;
                        user.CurrentState  = UserState.Room == user.CurrentState ? UserState.Online : user.CurrentState;
                    }
                }
                else
                {
                    user.CurrentRoomID = 0;
                    user.CurrentState  = UserState.Room == user.CurrentState ? UserState.Online : user.CurrentState;
                }

                LobbyServer.Instance.ForwardToWorld(user.UserSvrName, originalMsg);

                LogSys.Log(LOG_TYPE.INFO, "RoomServer User Quit Guid {0} State {1}", guid, user.CurrentState);
            }
        }
示例#15
0
        internal static void Execute(object msg, User user)
        {
            Msg_CRC_StopGfxImpact impact_msg = msg as Msg_CRC_StopGfxImpact;

            if (null != impact_msg)
            {
                Scene scene = user.OwnRoom.GetActiveScene();
                if (null != scene)
                {
                    CharacterInfo character = scene.SceneContext.GetCharacterInfoById(impact_msg.target_Id);
                    if (null != character && (character.GetId() == user.RoleId || character.OwnerId == user.RoleId))
                    {
                        ImpactSystem.Instance.OnGfxStopImpact(character, impact_msg.impact_Id);
                    }
                    else
                    {
                        if (null == character)
                        {
                            LogSys.Log(LOG_TYPE.ERROR, "StopGfxImpactHandler, charactor {0} not exist", impact_msg.target_Id);
                        }
                        else
                        {
                            LogSys.Log(LOG_TYPE.ERROR, "StopGfxImpactHandler, charactor {0} or owner {1} not user {2}", character.GetId(), character.OwnerId, user.RoleId);
                        }
                    }
                }
            }
        }
        //--------------------------------------------------------------------------------------------------------------------------
        //供外部通过QueueAction调用的方法,实际执行线程是DataCacheThread。
        //--------------------------------------------------------------------------------------------------------------------------
        internal void LoadAccount(string accountId)
        {
            Msg_LD_Load msg = new Msg_LD_Load();

            msg.MsgId = (int)DataEnum.TableAccount;
            msg.PrimaryKeys.Add(accountId);
            Msg_LD_SingleLoadRequest reqAccount = new Msg_LD_SingleLoadRequest();

            reqAccount.MsgId    = (int)DataEnum.TableAccount;
            reqAccount.LoadType = Msg_LD_SingleLoadRequest.LoadTypeEnum.LoadSingle;
            reqAccount.Keys.Add(accountId);
            msg.LoadRequests.Add(reqAccount);
            RequestLoad(msg, (ret) => {
                KeyString primaryKey = KeyString.Wrap(ret.PrimaryKeys);
                if (Msg_DL_LoadResult.ErrorNoEnum.Success == ret.ErrorNo)
                {
                    LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Green, "DataCache Load Success: Msg:{0}, Key:{1}", "Account", primaryKey);
                }
                else if (Msg_DL_LoadResult.ErrorNoEnum.NotFound == ret.ErrorNo)
                {
                    LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Yellow, "DataCache Load NotFound: Msg:{0}, Key:{1}", "Account", primaryKey);
                }
                else
                {
                    LogSys.Log(LOG_TYPE.ERROR, ConsoleColor.Red, "DataCache Load Failed: Msg:{0}, Key:{1}, ERROR:{2}", "Account", primaryKey, ret.ErrorInfo);
                }
                UserProcessScheduler dataProcessScheduler = UserServer.Instance.UserProcessScheduler;
                dataProcessScheduler.DefaultUserThread.QueueAction(dataProcessScheduler.LoadAccountCallback, accountId, ret);
            });
        }
示例#17
0
        internal static void Execute(object msg, User user)
        {
            Msg_CRC_InteractObject ctrlObj = msg as Msg_CRC_InteractObject;

            if (ctrlObj == null)
            {
                return;
            }
            UserInfo userInfo = user.Info;

            if (userInfo == null)
            {
                LogSys.Log(LOG_TYPE.ERROR, "charactor {0} not exist", user.RoleId);
                return;
            }
            Scene scene = user.OwnRoom.GetActiveScene();

            if (null != scene)
            {
                NpcInfo receiver = scene.NpcManager.GetNpcInfo(ctrlObj.receiver_id);
                if (null != receiver)
                {
                }
            }
        }
 private void InitGuidData()
 {
     if (m_GuidInitStatus == DataInitStatus.Unload)
     {
         if (UserServerConfig.DataStoreAvailable == true)
         {
             m_GuidInitStatus = DataInitStatus.Loading;
             Msg_LD_Load msg = new Msg_LD_Load();
             msg.MsgId = (int)DataEnum.TableGuid;
             GameFrameworkMessage.Msg_LD_SingleLoadRequest slr = new GameFrameworkMessage.Msg_LD_SingleLoadRequest();
             slr.MsgId    = (int)GameFrameworkData.DataEnum.TableGuid;
             slr.LoadType = GameFrameworkMessage.Msg_LD_SingleLoadRequest.LoadTypeEnum.LoadAll;
             slr.Keys.Clear();
             msg.LoadRequests.Add(slr);
             RequestLoad(msg, ((ret) => {
                 if (ret.ErrorNo == Msg_DL_LoadResult.ErrorNoEnum.Success)
                 {
                     List <GuidInfo> guidList = new List <GuidInfo>();
                     foreach (var singlerow in ret.Results)
                     {
                         object _msg;
                         if (DbDataSerializer.Decode(singlerow.Data, DataEnum2Type.Query(slr.MsgId), out _msg))
                         {
                             TableGuid dataGuid = _msg as TableGuid;
                             if (null != dataGuid)
                             {
                                 GuidInfo guidinfo = new GuidInfo();
                                 guidinfo.GuidType = dataGuid.GuidType;
                                 guidinfo.NextGuid = (long)dataGuid.GuidValue;
                                 guidList.Add(guidinfo);
                             }
                         }
                     }
                     UserServer.Instance.GlobalProcessThread.InitGuidData(guidList);
                     m_GuidInitStatus = DataInitStatus.Done;
                     LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Green, "Load DataCache global data success. Table:TableGuid");
                 }
                 else if (ret.ErrorNo == Msg_DL_LoadResult.ErrorNoEnum.NotFound)
                 {
                     //暂时初始化为空列表
                     List <GuidInfo> guidList = new List <GuidInfo>();
                     UserServer.Instance.GlobalProcessThread.InitGuidData(guidList);
                     m_GuidInitStatus = DataInitStatus.Done;
                     LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Green, "Load DataCache global data success. Table:TableGuid (empty)");
                 }
                 else
                 {
                     m_GuidInitStatus = DataInitStatus.Unload;
                     LogSys.Log(LOG_TYPE.ERROR, ConsoleColor.Red, "Load DataCache global data failed. Table: {0}", "TableGuid");
                 }
             }
                               ));
         }
         else
         {
             m_GuidInitStatus = DataInitStatus.Done;
             LogSys.Log(LOG_TYPE.INFO, "init guid done!");
         }
     }
 }
示例#19
0
    private void OnCommand(int src, int dest, string command)
    {
        const string c_QuitDataStore = "QuitDataStore";
        const string c_ReloadConfig  = "ReloadConfig";

        try {
            if (0 == command.CompareTo(c_QuitDataStore))
            {
                LogSys.Log(LOG_TYPE.MONITOR, "receive {0} command, save data and then quitting ...", command);
                if (!m_WaitQuit)
                {
                    DataCacheSystem.Instance.QueueAction(DataCacheSystem.Instance.DoLastSave);
                    m_WaitQuit = true;
                }
            }
            else if (0 == command.CompareTo(c_ReloadConfig))
            {
                CenterClientApi.ReloadConfigScript();
                DataCacheConfig.Init();
                LogSys.Log(LOG_TYPE.WARN, "receive {0} command.", command);
            }
        } catch (Exception ex) {
            LogSys.Log(LOG_TYPE.ERROR, "Exception {0}\n{1}", ex.Message, ex.StackTrace);
        }
    }
示例#20
0
        public void HandleClientMsg(int id, object msg, User user)
        {
            if (msg == null)
            {
                LogSys.Log(LOG_TYPE.ERROR, "{0}", "can't handle null msg");
                return;
            }
            ClientMsgHandler handler;

            if (!client_msg_handlers_.TryGetValue(id, out handler))
            {
                if (client_default_handler_ != null)
                {
                    client_default_handler_(msg, user);
                }
                else
                {
                    LogSys.Log(LOG_TYPE.ERROR, "{0}", "message no deal&default handler!");
                }
                return;
            }
            if (handler != null)
            {
                handler(msg, user);
            }
        }
示例#21
0
 private void OnNameHandleChanged(bool addOrUpdate, string name, int handle)
 {
     try {
         m_DataCacheChannel.OnUpdateNameHandle(addOrUpdate, name, handle);
         if (!addOrUpdate)
         {
             m_NodeHandles.Remove(handle);
             m_RoomSvrHandles.Remove(handle);
             m_UserHandles.Remove(handle);
         }
         if (0 == name.CompareTo("Lobby"))
         {
             if (addOrUpdate)
             {
                 m_MyHandle = handle;
             }
             else
             {
                 m_MyHandle = 0;
             }
         }
     } catch (Exception ex) {
         LogSys.Log(LOG_TYPE.ERROR, "Exception {0}\n{1}", ex.Message, ex.StackTrace);
     }
 }
示例#22
0
 internal void UpdateMaxUserCount(int maxUserCount, int maxUserCountPerLogicServer, int maxQueueingCount, int gowRobotType)
 {
     m_MaxOnlineUserCount = maxUserCount;
     m_MaxOnlineUserCountPerLogicServer = maxUserCountPerLogicServer;
     m_MaxQueueingCount = maxQueueingCount;
     LogSys.Log(LOG_TYPE.WARN, "UpdateMaxUserCount {0} {1} {2} {3}", maxUserCount, maxUserCountPerLogicServer, maxQueueingCount, gowRobotType);
 }
示例#23
0
        public void Destroy()
        {
            LogSys.Log(LOG_TYPE.INFO, "room {0}({1}) destroy.", RoomId, LocalID);
            OnDestroy();
            m_RoomUserMgr.ActiveScene.Reset();
            m_ScenePool.RecycleScene(m_RoomUserMgr.ActiveScene);
            m_RoomUserMgr.ActiveScene = null;

            this.CurrentState = RoomState.Unuse;
            int userCt = m_RoomUserMgr.RoomUsers.Count;

            for (int i = userCt - 1; i >= 0; --i)
            {
                User user = m_RoomUserMgr.RoomUsers[i];
                if (null != user)
                {
                    LogSys.Log(LOG_TYPE.INFO, "FreeUser {0} for {1} {2}, [Room.Destroy]", user.LocalID, user.Guid, user.GetKey());
                    user.Reset();
                    m_UserPool.FreeUser(user.LocalID);
                    m_RoomUserMgr.RoomUsers.RemoveAt(i);
                }
            }
            for (int i = 0; i < m_RoomUserMgr.RoomObservers.Length; ++i)
            {
                m_RoomUserMgr.RoomObservers[i].Reset();
            }
        }
示例#24
0
        private void ReceiveCallBack_Thread(IAsyncResult result)
        {
            Client        state  = (Client)result.AsyncState;
            NetworkStream stream = m_TcpClient.GetStream();
            int           code   = stream.EndRead(result);

            LogSys.Log(LOG_TYPE.ERROR, ConsoleColor.Blue, "ReceiveCallBack bytes={0} threadid={1} threadpool={2}", code, System.Threading.Thread.CurrentThread.ManagedThreadId, System.Threading.Thread.CurrentThread.IsThreadPoolThread);
            //LogSys.Log(LOG_TYPE.ERROR, "ReceiveCallBack code={0} bytes={1}", code, DataHelper.Bytes2HexString(m_ReadBytes));

            if (code > 0)
            {
                bool returnValue = m_TcpInPacket.WriteData(m_ReadBytes, 0, code);
                if (returnValue == true)
                {
                    Receive();
                }
                else
                {
                    LogSys.Log(LOG_TYPE.ERROR, "ReceiveCallBack writeDate error");
                    Close();
                }
            }
            else
            {
                LogSys.Log(LOG_TYPE.ERROR, "ReceiveCallBack close");
                Close();
            }
        }
示例#25
0
 public void Finish(int winnerCampID)
 {
     if (IsFieldRoom)
     {
         return;
     }
     if (this.CurrentState == RoomState.Finish || this.CurrentState == RoomState.Deactive)
     {
         return;
     }
     foreach (User user in m_RoomUserMgr.RoomUsers)
     {
         if (user != null)
         {
             Msg_RL_UserDrop unqBuilder = new Msg_RL_UserDrop();
             unqBuilder.RoomId      = m_RoomId;
             unqBuilder.UserGuid    = user.Guid;
             unqBuilder.IsBattleEnd = true;
             m_Connector.SendMsgToLobby(unqBuilder);
             user.LastNotifyUserDropTime = TimeUtility.GetLocalMilliseconds();
         }
     }
     this.CurrentState = RoomState.Finish;
     m_FinishTime      = TimeUtility.GetLocalMilliseconds();
     LogSys.Log(LOG_TYPE.DEBUG, "Room {0}({1}) EndBattle.", RoomId, LocalID);
 }
        protected override void OnTick()
        {
            try {
                long curTime = TimeUtility.GetLocalMilliseconds();
                if (m_LastTickTime != 0)
                {
                    long elapsedTickTime = curTime - m_LastTickTime;
                    if (elapsedTickTime > c_WarningTickTime)
                    {
                        LogSys.Log(LOG_TYPE.MONITOR, "SceneLoadThread Tick:{0}", elapsedTickTime);
                    }
                }
                m_LastTickTime = curTime;

                if (m_LastLogTime + 60000 < curTime)
                {
                    m_LastLogTime = curTime;

                    DebugPoolCount((string msg) => {
                        LogSys.Log(LOG_TYPE.INFO, "SceneLoadThread.ActionQueue {0}", msg);
                    });
                    LogSys.Log(LOG_TYPE.MONITOR, "SceneLoadThread.ActionQueue Current Action {0}", this.CurActionNum);
                }
            } catch (Exception ex) {
                LogSys.Log(LOG_TYPE.ERROR, "Exception {0}\n{1}", ex.Message, ex.StackTrace);
            }
        }
示例#27
0
        internal static void UpdateGowRank(UserInfo entity)
        {
            if (null == entity) return;
            GowRankConfig cfg = null;
            if (GowSystem.RankData.TryGetValue(entity.GowInfo.RankId, out cfg))
            {
                if (cfg.m_IsTriggerAdvance && IsInUpMetches(entity, cfg.m_Point))
                {
                    if (CanAdvanceRank(entity, cfg))
                    {
                        entity.GowInfo.RankId += 1;
                        entity.GowInfo.Point = 0;
                        entity.GowInfo.ResetCriticalData();
                    }
                }
                else if (cfg.m_IsTriggerReduced && IsInDownMetches(entity))
                {
                    if (CanReduceRank(entity, cfg))
                    {
                        entity.GowInfo.RankId -= 1;
                        entity.GowInfo.Point = 0;
                        entity.GowInfo.ResetCriticalData();
                    }
                }
            }

            LogSys.Log(LOG_TYPE.INFO, "gowrank entitynickname:{0},rank:{1},point:{2},total:{3},win:{4},loss:{5}",
              entity.Nickname, entity.GowInfo.RankId, entity.GowInfo.Point, entity.GowInfo.CriticalTotalMatches, entity.GowInfo.AmassWinMatches, entity.GowInfo.AmassLossMatches);
        }
示例#28
0
        internal static void Execute(object msg, User user)
        {
            Msg_CRC_NpcStopSkill end_skill = msg as Msg_CRC_NpcStopSkill;

            if (end_skill == null)
            {
                return;
            }
            Scene scene = user.OwnRoom.GetActiveScene();

            if (null != scene)
            {
                CharacterInfo charactor = scene.SceneContext.GetCharacterInfoById(end_skill.npc_id);
                if (charactor == null)
                {
                    LogSys.Log(LOG_TYPE.ERROR, "NpcStopSkillHandler, charactor {0} not exist", user.RoleId);
                    return;
                }
                if (charactor.OwnerId != user.RoleId)
                {
                    LogSys.Log(LOG_TYPE.ERROR, "NpcStopSkillHandler, charactor {0} owner {1} not user {2}", charactor.GetId(), charactor.OwnerId, user.RoleId);
                    return;
                }
                scene.SkillSystem.StopSkill(end_skill.npc_id);
                user.BroadCastMsgToRoom(end_skill);
            }
        }
        private void OnCommand(int worldId, int src, int dest, string command)
        {
            const string c_QuitLobby    = "QuitLobby";
            const string c_ReloadConfig = "ReloadConfig";

            try {
                if (worldId == UserServerConfig.WorldId)
                {
                    if (0 == command.CompareTo(c_QuitLobby))
                    {
                        LogSys.Log(LOG_TYPE.MONITOR, "receive {0} command, save data and then quitting ...", command);
                        if (!m_WaitQuit)
                        {
                            //收到关闭服务器指令,退出前保存数据
                            m_UserProcessScheduler.DefaultUserThread.QueueAction(m_UserProcessScheduler.DoLastSaveUserData);
                            m_GlobalProcessThread.QueueAction(m_GlobalProcessThread.DoLastSaveGlobalData);
                            m_LastWaitQuitTime = TimeUtility.GetLocalMilliseconds();
                            m_WaitQuit         = true;
                        }
                    }
                    else if (0 == command.CompareTo(c_ReloadConfig))
                    {
                        CenterHubApi.ReloadConfigScript();
                        UserServerConfig.Init();
                        LogSys.Log(LOG_TYPE.WARN, "receive {0} command.", command);
                    }
                }
                else
                {
                }
            } catch (Exception ex) {
                LogSys.Log(LOG_TYPE.ERROR, "Exception {0}\n{1}", ex.Message, ex.StackTrace);
            }
        }
示例#30
0
        internal void HandleBuyLife(ulong guid)
        {
            UserProcessScheduler scheduler = LobbyServer.Instance.UserProcessScheduler;

            if (null == scheduler)
            {
                return;
            }
            // 响应玩家要求复活
            UserInfo user = scheduler.GetUserInfo(guid);

            if (null != user)
            {
                RoomInfo room = user.Room;
                if (null != room)
                {
                    Msg_LR_UserReLive resultBuilder = new Msg_LR_UserReLive();
                    resultBuilder.UserGuid = guid;
                    resultBuilder.RoomId   = user.CurrentRoomID;
                    LobbyServer.Instance.RoomSvrChannel.Send(room.RoomServerName, resultBuilder);

                    LogSys.Log(LOG_TYPE.INFO, "BuyLife Guid {0}", guid);
                }
            }
        }