Init() public static method

public static Init ( string config ) : bool
config string
return bool
示例#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");
    }
示例#2
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");
    }
示例#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("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");
    }
        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;
            CenterHubApi.SetCenterLogHandler(m_LogHandler);
            CenterHubApi.Init("userserver", args.Length, args, m_NameHandleCallback, m_MsgCallback, m_MsgResultCallback, m_CmdCallback);

            LogSys.Init("./config/logconfig.xml");
            UserServerConfig.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;
                }
            };

            LoadData();
            LogSys.Log(LOG_TYPE.INFO, "Init Config ...");
            s_Instance = this;
            InstallMessageHandlers();
            LogSys.Log(LOG_TYPE.INFO, "Init Messenger ...");
            m_DataCacheThread.Init(m_DataCacheChannel);
            LogSys.Log(LOG_TYPE.INFO, "Init DataCache ...");
            Start();
            LogSys.Log(LOG_TYPE.INFO, "Start Threads ...");
        }
示例#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("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.");
        }
示例#6
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.");
        }
示例#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("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 ...");
        }