Example #1
0
    private void Init(string[] args)
    {
        m_NameHandleCallback = this.OnNameHandleChanged;
        m_MsgCallback        = this.OnMessage;
        m_MsgResultCallback  = this.OnMessageResultCallback;
        m_CmdCallback        = this.OnCommand;
        m_LogHandler         = this.OnCenterLog;
        CenterClientApi.SetCenterLogHandler(m_LogHandler);
        CenterClientApi.Init("datacache", args.Length, args, m_NameHandleCallback, m_MsgCallback, m_MsgResultCallback, m_CmdCallback);

        m_Channel = new PBChannel(DataMessageEnum2Type.Query,
                                  DataMessageEnum2Type.Query);
        m_Channel.DefaultServiceName = "UserSvr";
        LogSys.Init("./config/logconfig.xml");
        DataCacheConfig.Init();

        GlobalVariables.Instance.IsClient = false;

        string key = "防君子不防小人";

        byte[] xor = Encoding.UTF8.GetBytes(key);

        ResourceReadProxy.OnReadAsArray = ((string filePath) => {
            byte[] buffer = null;
            try {
                buffer = File.ReadAllBytes(filePath);
            } catch (Exception e) {
                LogSys.Log(LOG_TYPE.ERROR, "Exception:{0}\n{1}", e.Message, e.StackTrace);
                return(null);
            }
            return(buffer);
        });
        LogSystem.OnOutput += (Log_Type type, string msg) => {
            switch (type)
            {
            case Log_Type.LT_Debug:
                LogSys.Log(LOG_TYPE.DEBUG, msg);
                break;

            case Log_Type.LT_Info:
                LogSys.Log(LOG_TYPE.INFO, msg);
                break;

            case Log_Type.LT_Warn:
                LogSys.Log(LOG_TYPE.WARN, msg);
                break;

            case Log_Type.LT_Error:
            case Log_Type.LT_Assert:
                LogSys.Log(LOG_TYPE.ERROR, msg);
                break;
            }
        };

        DbThreadManager.Instance.Init(DataCacheConfig.LoadThreadNum, DataCacheConfig.SaveThreadNum);
        DataOpSystem.Instance.Init(m_Channel);
        DataCacheSystem.Instance.Init();
        LogSys.Log(LOG_TYPE.INFO, "DataCache initialized");
    }
Example #2
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
        }
Example #3
0
    private void Init(string[] args)
    {
        m_NameHandleCallback = this.OnNameHandleChanged;
        m_MsgCallback        = this.OnMessage;
        m_CmdCallback        = this.OnCommand;
        m_MsgResultCallback  = this.OnMessageResult;
        CenterClientApi.Init("store", args.Length, args, m_NameHandleCallback, m_MsgCallback, m_MsgResultCallback, m_CmdCallback);

        m_Channel = new PBChannel(DashFire.DataStore.MessageMapping.Query,
                                  DashFire.DataStore.MessageMapping.Query);
        m_Channel.DefaultServiceName = "Lobby";
        LogSys.Init("./config/logconfig.xml");
        DataStoreConfig.Init();

        ArkCrossEngine.GlobalVariables.Instance.IsClient = false;

        FileReaderProxy.RegisterReadFileHandler((string filePath) =>
        {
            byte[] buffer = null;
            try
            {
                buffer = File.ReadAllBytes(filePath);
            }
            catch (Exception e)
            {
                LogSys.Log(LOG_TYPE.ERROR, "Exception:{0}\n{1}", e.Message, e.StackTrace);
                return(null);
            }
            return(buffer);
        }, (string filepath) => { return(File.Exists(filepath)); });
        LogSystem.OnOutput += (Log_Type type, string msg) =>
        {
            switch (type)
            {
            case Log_Type.LT_Debug:
                LogSys.Log(LOG_TYPE.DEBUG, msg);
                break;

            case Log_Type.LT_Info:
                LogSys.Log(LOG_TYPE.INFO, msg);
                break;

            case Log_Type.LT_Warn:
                LogSys.Log(LOG_TYPE.WARN, msg);
                break;

            case Log_Type.LT_Error:
            case Log_Type.LT_Assert:
                LogSys.Log(LOG_TYPE.ERROR, msg);
                break;
            }
        };

        DbThreadManager.Instance.Init(DataStoreConfig.LoadThreadNum, DataStoreConfig.SaveThreadNum);
        DataOpSystem.Instance.Init(m_Channel);
        DataCacheSystem.Instance.Init();
        LogSys.Log(LOG_TYPE.INFO, "DataStore initialized");
    }
Example #4
0
    private void Init(string[] args)
    {
        m_NameHandleCallback = this.OnNameHandleChanged;
        m_MsgCallback        = this.OnMessage;
        m_CmdCallback        = this.OnCommand;
        m_MsgResultCallback  = this.OnMessageResult;
        CenterClientApi.Init("bridge", args.Length, args, m_NameHandleCallback, m_MsgCallback, m_MsgResultCallback, m_CmdCallback);

        m_Channel = new PBChannel(DashFire.Billing.MessageMapping.Query,
                                  DashFire.Billing.MessageMapping.Query);
        m_Channel.DefaultServiceName = "Lobby";
        m_Channel.Register <LB_VerifyAccount>(HandleVerifyAccount);

        LogSys.Init("./config/logconfig.xml");

        StringBuilder sb = new StringBuilder(256);

        if (CenterClientApi.GetConfig("AppKey", sb, 256))
        {
            m_AppKey = sb.ToString();
        }
        if (CenterClientApi.GetConfig("AppSecret", sb, 256))
        {
            m_AppSecret = sb.ToString();
        }
        if (CenterClientApi.GetConfig("BillingServerUrl", sb, 256))
        {
            m_BillingServerUrl = sb.ToString();
        }
        if (CenterClientApi.GetConfig("TestBillingServerUrl", sb, 256))
        {
            m_TestBillingServerUrl = sb.ToString();
        }
        if (CenterClientApi.GetConfig("HttpRequestTimeout", sb, 256))
        {
            m_HttpRequestTimeout = int.Parse(sb.ToString());
        }

        LogSys.Log(LOG_TYPE.INFO, "BillingSystem initialized");
    }
Example #5
0
        private void Init(string[] args)
        {
            m_NameHandleCallback = this.OnNameHandleChanged;
            m_MsgCallback        = this.OnMessage;
            m_MsgResultCallback  = this.OnMessageResultCallback;
            m_CmdCallback        = this.OnCommand;
            m_LogHandler         = this.OnCenterLog;
            CenterClientApi.SetCenterLogHandler(m_LogHandler);
            CenterClientApi.Init("lobby", args.Length, args, m_NameHandleCallback, m_MsgCallback, m_MsgResultCallback, m_CmdCallback);

            LogSys.Init("./config/logconfig.xml");
            LobbyConfig.Init();

            if (LobbyConfig.IsDebug)
            {
                GlobalVariables.Instance.IsDebug = true;
            }

            GlobalVariables.Instance.IsClient = false;

            ResourceReadProxy.OnReadAsArray = ((string filePath) => {
                byte[] buffer = null;
                try {
                    buffer = File.ReadAllBytes(filePath);
                } catch (Exception e) {
                    LogSys.Log(LOG_TYPE.ERROR, "Exception:{0}\n{1}", e.Message, e.StackTrace);
                    return(null);
                }
                return(buffer);
            });
            LogSystem.OnOutput += (Log_Type type, string msg) => {
                switch (type)
                {
                case Log_Type.LT_Debug:
                    LogSys.Log(LOG_TYPE.DEBUG, msg);
                    break;

                case Log_Type.LT_Info:
                    LogSys.Log(LOG_TYPE.INFO, msg);
                    break;

                case Log_Type.LT_Warn:
                    LogSys.Log(LOG_TYPE.WARN, msg);
                    break;

                case Log_Type.LT_Error:
                case Log_Type.LT_Assert:
                    LogSys.Log(LOG_TYPE.ERROR, msg);
                    break;
                }
            };

            LoadData();
            LogSys.Log(LOG_TYPE.INFO, "Init Config ...");
            s_Instance = this;
            InstallMessageHandlers();
            LogSys.Log(LOG_TYPE.INFO, "Init Messenger ...");
            m_RoomProcessThread.Init();
            LogSys.Log(LOG_TYPE.INFO, "Init RoomProcessThread ...");
            Start();
            LogSys.Log(LOG_TYPE.INFO, "Start Threads ...");
        }
        private void Init(string[] args)
        {
            m_NameHandleCallback = this.OnNameHandleChanged;
            m_MsgCallback        = this.OnMessage;
            m_MsgResultCallback  = this.OnMessageResultCallback;
            m_CmdCallback        = this.OnCommand;
            m_LogHandler         = this.OnCenterLog;
            CenterClientApi.SetCenterLogHandler(m_LogHandler);
            CenterClientApi.Init("roomserver", args.Length, args, m_NameHandleCallback, m_MsgCallback, m_MsgResultCallback, m_CmdCallback);

            Console.WriteLine("begin init roomserver...");
            HomePath.InitHomePath();

            bool ret = LogSys.Init("./config/logconfig.xml");

            System.Diagnostics.Debug.Assert(ret);

            m_LastTickTimeForSend  = TimeUtility.GetLocalMilliseconds();
            m_LastSendRoomInfoTime = m_LastTickTimeForSend;
            m_IsContinueRegister   = true;
            m_Channel = new PBChannel(BigworldAndRoomServerMessageEnum2Type.Query, BigworldAndRoomServerMessageEnum2Type.Query);
            m_Channel.DefaultServiceName = "Lobby";
            m_LobbyConnector             = new Connector(m_Channel);

            m_ServerIp   = "127.0.0.1";
            m_ServerPort = 9528;

            InitConfig();

            GlobalVariables.Instance.IsClient = false;

            string key = "防君子不防小人";

            byte[] xor = Encoding.UTF8.GetBytes(key);

            ResourceReadProxy.OnReadAsArray = ((string filePath) => {
                byte[] buffer = null;
                try {
                    buffer = File.ReadAllBytes(filePath);
                } catch (Exception e) {
                    LogSys.Log(LOG_TYPE.ERROR, "Exception:{0}\n{1}", e.Message, e.StackTrace);
                    return(null);
                }
                return(buffer);
            });
            LogSystem.OnOutput += (Log_Type type, string msg) => {
                switch (type)
                {
                case Log_Type.LT_Debug:
                    LogSys.Log(LOG_TYPE.DEBUG, msg);
                    break;

                case Log_Type.LT_Info:
                    LogSys.Log(LOG_TYPE.INFO, msg);
                    break;

                case Log_Type.LT_Warn:
                    LogSys.Log(LOG_TYPE.WARN, msg);
                    break;

                case Log_Type.LT_Error:
                case Log_Type.LT_Assert:
                    LogSys.Log(LOG_TYPE.ERROR, msg);
                    break;
                }
            };

            LoadData();
            LogSys.Log(LOG_TYPE.DEBUG, "room server init ip: {0}  port: {1}", m_ServerIp, m_ServerPort);

            uint tick_interval = 33;

            m_RoomMgr = new RoomManager(1280, c_ThreadCount, c_PerThreadRoomCount, tick_interval, m_LobbyConnector);
            m_RoomMgr.Init(m_RoomServerName);
            IOManager.Instance.Init((int)m_ServerPort);
            m_RoomMgr.StartRoomThread();
            SceneLogicViewManager.Instance.Init();

            ServerStorySystem.StaticInit();
            GameFramework.GmCommands.GmStorySystem.StaticInit();

            m_Channel.Register <Msg_LR_ReplyRegisterRoomServer>(HandleReplyRegisterRoomServer);
            m_RoomMgr.RegisterMsgHandler(m_Channel);

            LogSys.Log(LOG_TYPE.DEBUG, "room server init ok.");
        }
Example #7
0
        private void Init(string[] args)
        {
            m_NameHandleCallback = this.OnNameHandleChanged;
            m_MsgCallback        = this.OnMessage;
            m_CmdCallback        = this.OnCommand;
            m_MsgResultCallback  = this.OnMessageResult;
            CenterClientApi.Init("roomserver", args.Length, args, m_NameHandleCallback, m_MsgCallback, m_MsgResultCallback, m_CmdCallback);

            Console.WriteLine("begin init roomserver...");
            HomePath.InitHomePath();

            bool ret = LogSys.Init("./config/logconfig.xml");

            System.Diagnostics.Debug.Assert(ret);

            last_tick_time_          = TimeUtility.GetServerMilliseconds();
            last_send_roominfo_time_ = last_tick_time_;
            is_continue_register_    = true;
            channel_ = new PBChannel(MessageMapping.Query, MessageMapping.Query);
            channel_.DefaultServiceName = "Lobby";
            lobby_connector_            = new Connector(channel_);

            server_ip_   = "127.0.0.1";
            server_port_ = 9528;

            StringBuilder sb = new StringBuilder(256);

            if (CenterClientApi.GetConfig("name", sb, 256))
            {
                room_server_name_ = sb.ToString();
            }
            if (CenterClientApi.GetConfig("ServerIp", sb, 256))
            {
                server_ip_ = sb.ToString();
            }
            if (CenterClientApi.GetConfig("ServerPort", sb, 256))
            {
                server_port_ = uint.Parse(sb.ToString());
            }
            if (CenterClientApi.GetConfig("Debug", sb, 256))
            {
                int debug = int.Parse(sb.ToString());
                if (debug != 0)
                {
                    GlobalVariables.Instance.IsDebug = true;
                }
            }

            GlobalVariables.Instance.IsClient = false;

            FileReaderProxy.RegisterReadFileHandler((string filePath) =>
            {
                byte[] buffer = null;
                try
                {
                    buffer = File.ReadAllBytes(filePath);
                }
                catch (Exception e)
                {
                    LogSys.Log(LOG_TYPE.ERROR, "Exception:{0}\n{1}", e.Message, e.StackTrace);
                    return(null);
                }
                return(buffer);
            }, (string filepath) => { return(File.Exists(filepath)); });
            LogSystem.OnOutput += (Log_Type type, string msg) =>
            {
                switch (type)
                {
                case Log_Type.LT_Debug:
                    LogSys.Log(LOG_TYPE.DEBUG, msg);
                    break;

                case Log_Type.LT_Info:
                    LogSys.Log(LOG_TYPE.INFO, msg);
                    break;

                case Log_Type.LT_Warn:
                    LogSys.Log(LOG_TYPE.WARN, msg);
                    break;

                case Log_Type.LT_Error:
                case Log_Type.LT_Assert:
                    LogSys.Log(LOG_TYPE.ERROR, msg);
                    break;
                }
            };

            LoadData();

            LogSys.Log(LOG_TYPE.DEBUG, "room server init ip: {0}  port: {1}", server_ip_, server_port_);

            ret = Serialize.Init();
            if (!ret)
            {
                LogSys.Log(LOG_TYPE.DEBUG, "Serialize init error !!!");
            }
            else
            {
                LogSys.Log(LOG_TYPE.DEBUG, "Serialize init OK.");
            }

            thread_count_          = 16;
            per_thread_room_count_ = 20;
            uint tick_interval = 50;

            room_mgr_ = new RoomManager(thread_count_, per_thread_room_count_,
                                        tick_interval, lobby_connector_);
            room_mgr_.Init();
            IOManager.Instance.Init((int)server_port_);
            room_mgr_.StartRoomThread();
            AiViewManager.Instance.Init();
            SceneLogicViewManager.Instance.Init();
            ImpactViewManager.Instance.Init();

            ServerSkillSystem.StaticInit();
            ServerStorySystem.StaticInit();
            DashFire.GmCommands.GmStorySystem.StaticInit();

            channel_.Register <Msg_LR_ReplyRegisterRoomServer>(HandleReplyRegisterRoomServer);
            room_mgr_.RegisterMsgHandler(channel_);

            LogSys.Log(LOG_TYPE.DEBUG, "room server init ok.");
        }
Example #8
0
        private void Init(string[] args)
        {
            m_NameHandleCallback = this.OnNameHandleChanged;
            m_MsgCallback        = this.OnMessage;
            m_CmdCallback        = this.OnCommand;
            m_MsgResultCallback  = this.OnMessageResult;
            CenterClientApi.Init("lobby", args.Length, args, m_NameHandleCallback, m_MsgCallback, m_MsgResultCallback, m_CmdCallback);

            LogSys.Init("./config/logconfig.xml");
            LobbyConfig.Init();

            if (LobbyConfig.IsDebug)
            {
                GlobalVariables.Instance.IsDebug = true;
            }

            GlobalVariables.Instance.IsClient = false;

            FileReaderProxy.RegisterReadFileHandler((string filePath) =>
            {
                byte[] buffer = null;
                try
                {
                    buffer = File.ReadAllBytes(filePath);
                }
                catch (Exception e)
                {
                    LogSys.Log(LOG_TYPE.ERROR, "Exception:{0}\n{1}", e.Message, e.StackTrace);
                    return(null);
                }
                return(buffer);
            }, (string filePath) =>
            {
                return(File.Exists(filePath));
            });
            LogSystem.OnOutput += (Log_Type type, string msg) =>
            {
                switch (type)
                {
                case Log_Type.LT_Debug:
                    LogSys.Log(LOG_TYPE.DEBUG, msg);
                    break;

                case Log_Type.LT_Info:
                    LogSys.Log(LOG_TYPE.INFO, msg);
                    break;

                case Log_Type.LT_Warn:
                    LogSys.Log(LOG_TYPE.WARN, msg);
                    break;

                case Log_Type.LT_Error:
                case Log_Type.LT_Assert:
                    LogSys.Log(LOG_TYPE.ERROR, msg);
                    break;
                }
            };

            LoadData();

            LogSys.Log(LOG_TYPE.INFO, "Init Config ...");
            s_Instance = this;
            InstallMessageHandlers();
            LogSys.Log(LOG_TYPE.INFO, "Init Messenger ...");
            m_DataStoreThread.Init(m_StoreChannel);
            LogSys.Log(LOG_TYPE.INFO, "Init DataStore ...");
            m_ServerBridgeThread.Init(m_BridgeChannel);
            LogSys.Log(LOG_TYPE.INFO, "Init BillingClient ...");
            m_GmServerThread.Init(m_GmSvrChannel);
            LogSys.Log(LOG_TYPE.INFO, "Init GmServerThread ...");
            Start();
            LogSys.Log(LOG_TYPE.INFO, "Start Threads ...");
        }