Exemple #1
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);
        }
    }
Exemple #2
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);
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
#if TEST_CENTER_CLIENT
            CenterClientApi.HandleNameHandleChangedCallback cb1 = HandleNameHandleChanged;
            CenterClientApi.HandleMessageCallback           cb2 = HandleMessage;
            CenterClientApi.HandleMessageResultCallback     cb3 = HandleMessageResult;
            CenterClientApi.HandleCommandCallback           cb4 = HandleCommand;
            byte[] bytes = Encoding.ASCII.GetBytes("test test test");
            CenterClientApi.Init("csharpclient", args.Length, args, cb1, cb2, cb3, cb4);

            CenterClientApi.ReloadConfigScript();
            CenterClientApi.ReloadConfigScript();

            for (; ;)
            {
                CenterClientApi.Tick();
                Thread.Sleep(10);

                int handle = CenterClientApi.TargetHandle("ServerCenter");
                if (handle > 0)
                {
                    bool ret = CenterClientApi.SendByHandle(handle, bytes, (ushort)bytes.Length);
                    CenterClientApi.SendCommandByHandle(handle, "output('test test test');");
                }
            }
            //CenterClientApi.Release();
#else
            CenterHubApi.HandleNameHandleChangedCallback cb1 = HandleNameHandleChanged2;
            CenterHubApi.HandleMessageCallback           cb2 = HandleMessage2;
            CenterHubApi.HandleMessageResultCallback     cb3 = HandleMessageResult2;
            CenterHubApi.HandleCommandCallback           cb4 = HandleCommand2;
            byte[] bytes = Encoding.ASCII.GetBytes("test test test");
            CenterHubApi.Init("centerhub", args.Length, args, cb1, cb2, cb3, cb4);

            CenterHubApi.ReloadConfigScript();
            CenterHubApi.ReloadConfigScript();

            for (; ;)
            {
                CenterHubApi.Tick();
                Thread.Sleep(10);

                int handle = CenterHubApi.TargetHandle(0, "hub2world0");
                if (handle > 0)
                {
                    bool ret = CenterHubApi.SendByHandle(0, handle, bytes, (ushort)bytes.Length);
                    CenterHubApi.SendCommandByHandle(0, handle, "output('test test test');");
                }
                handle = CenterHubApi.TargetHandle(1, "hub2world1");
                if (handle > 0)
                {
                    bool ret = CenterHubApi.SendByHandle(1, handle, bytes, (ushort)bytes.Length);
                    CenterHubApi.SendCommandByHandle(1, handle, "output('test test test');");
                }
            }
            //CenterHubApi.Release();
#endif
        }
        private void OnCommand(int src, int dest, string command)
        {
            const string c_QuitRoomServer = "QuitRoomServer";
            const string c_ReloadConfig   = "ReloadConfig";

            try {
                if (0 == command.CompareTo(c_QuitRoomServer))
                {
                    LogSys.Log(LOG_TYPE.MONITOR, "receive {0} command, quit", command);
                    CenterClientApi.Quit();
                }
                else if (0 == command.CompareTo(c_ReloadConfig))
                {
                    CenterClientApi.ReloadConfigScript();
                    InitConfig();
                    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);
            }
        }