示例#1
0
    internal static void Init()
    {
        StringBuilder sb = new StringBuilder(256);

        if (CenterClientApi.GetConfig("Server", sb, 256))
        {
            s_Instance.m_Server = sb.ToString();
        }
        if (CenterClientApi.GetConfig("User", sb, 256))
        {
            s_Instance.m_User = sb.ToString();
        }
        if (CenterClientApi.GetConfig("Password", sb, 256))
        {
            s_Instance.m_Password = sb.ToString();
        }
        if (CenterClientApi.GetConfig("Database", sb, 256))
        {
            s_Instance.m_Database = sb.ToString();
        }
        if (CenterClientApi.GetConfig("PersistentInterval", sb, 256))
        {
            s_Instance.m_PersistentInterval = uint.Parse(sb.ToString());
        }
        if (CenterClientApi.GetConfig("LoadThreadNum", sb, 256))
        {
            s_Instance.m_LoadThreadNum = int.Parse(sb.ToString());
        }
        if (CenterClientApi.GetConfig("SaveThreadNum", sb, 256))
        {
            s_Instance.m_SaveThreadNum = int.Parse(sb.ToString());
        }
    }
示例#2
0
    internal static void Init()
    {
        StringBuilder sb = new StringBuilder(256);

        if (CenterClientApi.GetConfig("Debug", sb, 256))
        {
            string debug = sb.ToString();
            s_Instance.m_Debug = (int.Parse(debug) != 0 ? true : false);

            if (s_Instance.m_Debug)
            {
                GameFramework.GlobalVariables.Instance.IsDebug = true;
            }
        }

        if (CenterClientApi.GetConfig("worldid", sb, 256))
        {
            string worldid = sb.ToString();
            int    val     = int.Parse(worldid);
            if (s_Instance.m_WorldId != val)
            {
                s_Instance.m_WorldId = val;
            }
        }
    }
示例#3
0
        internal void Init(int port)
        {
            InitMessageHandler();

            int           receiveBufferSize = 64;
            int           sendBufferSize    = 64;
            StringBuilder sb = new StringBuilder(256);

            if (CenterClientApi.GetConfig("ReceiveBufferSize", sb, 256))
            {
                receiveBufferSize = int.Parse(sb.ToString());
            }
            if (CenterClientApi.GetConfig("SendBufferSize", sb, 256))
            {
                sendBufferSize = int.Parse(sb.ToString());
            }

            m_Config = new NetPeerConfiguration("RoomServer");
            m_Config.MaximumConnections = 1024;
            m_Config.ConnectionTimeout  = 5.0f;
            m_Config.PingInterval       = 1.0f;
            m_Config.ReceiveBufferSize  = receiveBufferSize * 1024 * 1024;
            m_Config.SendBufferSize     = sendBufferSize * 1024 * 1024;
            m_Config.Port = port;
            m_Config.DisableMessageType(NetIncomingMessageType.DebugMessage);
            m_Config.DisableMessageType(NetIncomingMessageType.VerboseDebugMessage);
            //m_Config.EnableMessageType(NetIncomingMessageType.DebugMessage);
            //m_Config.EnableMessageType(NetIncomingMessageType.VerboseDebugMessage);
            m_Config.EnableMessageType(NetIncomingMessageType.ErrorMessage);
            m_Config.EnableMessageType(NetIncomingMessageType.WarningMessage);

            if (m_Config.IsMessageTypeEnabled(NetIncomingMessageType.DebugMessage))
            {
                LogSys.Log(LOG_TYPE.DEBUG, "Enable NetIncomingMessageType.DebugMessage");
            }
            if (m_Config.IsMessageTypeEnabled(NetIncomingMessageType.VerboseDebugMessage))
            {
                LogSys.Log(LOG_TYPE.DEBUG, "Enable NetIncomingMessageType.VerboseDebugMessage");
            }
            if (m_Config.IsMessageTypeEnabled(NetIncomingMessageType.ErrorMessage))
            {
                LogSys.Log(LOG_TYPE.DEBUG, "Enable NetIncomingMessageType.ErrorMessage");
            }
            if (m_Config.IsMessageTypeEnabled(NetIncomingMessageType.WarningMessage))
            {
                LogSys.Log(LOG_TYPE.DEBUG, "Enable NetIncomingMessageType.WarningMessage");
            }

            m_NetServer = new NetServer(m_Config);
            m_NetServer.Start();
            m_IOThread              = new Thread(new ThreadStart(IOHandler));
            m_IOThread.Name         = "IOHandler";
            m_IOThread.IsBackground = true;
            m_Status = RoomSrvStatus.STATUS_RUNNING;
            m_IOThread.Start();
            RoomPeerMgr.Instance.Init();
            Console.WriteLine("Init IOManager OK!");
        }
示例#4
0
    public static void Init()
    {
        StringBuilder sb = new StringBuilder(256);

        if (CenterClientApi.GetConfig("DSRequestTimeout", sb, 256))
        {
            s_Instance.m_DSRequestTimeout = uint.Parse(sb.ToString());
        }
    }
示例#5
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");
    }
示例#6
0
 private void InitConfig()
 {
     try {
         StringBuilder sb = new StringBuilder(256);
         if (CenterClientApi.GetConfig("name", sb, 256))
         {
             string str = sb.ToString();
             if (null == m_RoomServerName || 0 != m_RoomServerName.CompareTo(str))
             {
                 m_RoomServerName = str;
             }
         }
         if (CenterClientApi.GetConfig("ServerIp", sb, 256))
         {
             string str = sb.ToString();
             if (null == m_ServerIp || 0 != m_ServerIp.CompareTo(str))
             {
                 m_ServerIp = str;
             }
         }
         if (CenterClientApi.GetConfig("ServerPort", sb, 256))
         {
             uint port = uint.Parse(sb.ToString());
             if (m_ServerPort != port)
             {
                 m_ServerPort = port;
             }
         }
         if (CenterClientApi.GetConfig("Debug", sb, 256))
         {
             int debug = int.Parse(sb.ToString());
             if (debug != 0)
             {
                 GlobalVariables.Instance.IsDebug = true;
             }
         }
     } catch (Exception ex) {
         LogSys.Log(LOG_TYPE.ERROR, "RoomServer.InitConfig throw exception:{0}\n{1}", ex.Message, ex.StackTrace);
     }
 }
示例#7
0
    internal static void Init()
    {
        StringBuilder sb = new StringBuilder(256);

        if (CenterClientApi.GetConfig("DataStoreFlag", sb, 256))
        {
            string dsflag = sb.ToString();
            s_Instance.m_DataStoreFlag = (int.Parse(dsflag) != 0 ? true : false);
        }

        if (CenterClientApi.GetConfig("GMServerFlag", sb, 256))
        {
            string gsflag = sb.ToString();
            s_Instance.m_GMServerFlag = (int.Parse(gsflag) != 0 ? true : false);
        }

        if (CenterClientApi.GetConfig("Debug", sb, 256))
        {
            string debug = sb.ToString();
            s_Instance.m_Debug = (int.Parse(debug) != 0 ? true : false);
        }

        if (CenterClientApi.GetConfig("AppKey", sb, 256))
        {
            string appkey = sb.ToString();
            s_Instance.m_AppKey = appkey;
        }

        if (CenterClientApi.GetConfig("IOSGameChannel", sb, 256))
        {
            string iosgamechannel = sb.ToString();
            s_Instance.m_IOSGameChannel = iosgamechannel;
        }

        if (CenterClientApi.GetConfig("AndroidGameChannel", sb, 256))
        {
            string androidgamechannel = sb.ToString();
            s_Instance.m_AndroidGameChannel = androidgamechannel;
        }

        if (CenterClientApi.GetConfig("LogNormVersion", sb, 256))
        {
            string normver = sb.ToString();
            s_Instance.m_LogNormVersion = normver;
        }

        if (CenterClientApi.GetConfig("UserSaveInterval", sb, 256))
        {
            string saveinterval = sb.ToString();
            s_Instance.m_UserSaveInterval = int.Parse(saveinterval);
        }

        if (CenterClientApi.GetConfig("ServerId", sb, 256))
        {
            string serverid = sb.ToString();
            s_Instance.m_ServerId = uint.Parse(serverid);
        }
        if (CenterClientApi.GetConfig("ActivateCodeAvailable", sb, 256))
        {
            string activatecode = sb.ToString();
            s_Instance.m_ActivateCodeAvailable = (int.Parse(activatecode) != 0 ? true : false);
        }
        if (CenterClientApi.GetConfig("worldid", sb, 256))
        {
            string worldid = sb.ToString();
            s_Instance.m_WorldId = int.Parse(worldid);
        }
    }
示例#8
0
 internal static void Init()
 {
     try {
         StringBuilder sb = new StringBuilder(256);
         if (CenterClientApi.GetConfig("IsPersistent", sb, 256))
         {
             string str = sb.ToString();
             s_Instance.m_IsPersistent = int.Parse(str) != 0;
         }
         if (CenterClientApi.GetConfig("Server", sb, 256))
         {
             string str = sb.ToString();
             if (null == s_Instance.m_Server || 0 != s_Instance.m_Server.CompareTo(str))
             {
                 s_Instance.m_Server = str;
             }
         }
         if (CenterClientApi.GetConfig("User", sb, 256))
         {
             string str = sb.ToString();
             if (null == s_Instance.m_User || 0 != s_Instance.m_User.CompareTo(str))
             {
                 s_Instance.m_User = str;
             }
         }
         if (CenterClientApi.GetConfig("Password", sb, 256))
         {
             string str = sb.ToString();
             if (null == s_Instance.m_Password || 0 != s_Instance.m_Password.CompareTo(str))
             {
                 s_Instance.m_Password = str;
             }
         }
         if (CenterClientApi.GetConfig("Database", sb, 256))
         {
             string str = sb.ToString();
             if (null == s_Instance.m_Database || 0 != s_Instance.m_Database.CompareTo(str))
             {
                 s_Instance.m_Database = str;
             }
         }
         if (CenterClientApi.GetConfig("PersistentInterval", sb, 256))
         {
             uint val = uint.Parse(sb.ToString());
             if (s_Instance.m_PersistentInterval != val)
             {
                 s_Instance.m_PersistentInterval = val;
             }
         }
         if (CenterClientApi.GetConfig("LoadThreadNum", sb, 256))
         {
             int val = int.Parse(sb.ToString());
             if (s_Instance.m_LoadThreadNum != val)
             {
                 s_Instance.m_LoadThreadNum = val;
             }
         }
         if (CenterClientApi.GetConfig("SaveThreadNum", sb, 256))
         {
             int val = int.Parse(sb.ToString());
             if (s_Instance.m_SaveThreadNum != val)
             {
                 s_Instance.m_SaveThreadNum = val;
             }
         }
         if (CenterClientApi.GetConfig("TablePieceCapacity", sb, 256))
         {
             int val = int.Parse(sb.ToString());
             if (s_Instance.m_TablePieceCapacity != val)
             {
                 s_Instance.m_TablePieceCapacity = val;
             }
         }
     } catch (Exception ex) {
         LogSys.Log(LOG_TYPE.ERROR, "DataStoreConfig.Init throw exception:{0}\n{1}", ex.Message, ex.StackTrace);
     }
 }
示例#9
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.");
        }