Exemplo n.º 1
0
        public override void AfterInit()
        {
            mxEventProcessModule = GetMng().GetModule <NFCEventModule>();
            mxKernelModule       = GetMng().GetModule <NFIKernelModule>();
            mxLogicClassModule   = GetMng().GetModule <NFILogicClassModule>();
            mxElementInfoModule  = GetMng().GetModule <NFIElementModule>();

            System.Diagnostics.Debug.Assert(null != mxEventProcessModule);
            System.Diagnostics.Debug.Assert(null != mxKernelModule);
            System.Diagnostics.Debug.Assert(null != mxLogicClassModule);
            System.Diagnostics.Debug.Assert(null != mxElementInfoModule);

            NFILogicClass xLogicClass = mxLogicClassModule.GetElement("Server");

            if (xLogicClass != null)
            {
                List <string> xNameList = xLogicClass.GetConfigNameList();

                foreach (string strConfigName in xNameList)
                {
                    long nServerID   = mxElementInfoModule.QueryPropertyInt(strConfigName, "ServerID");
                    long nServerType = mxElementInfoModule.QueryPropertyInt(strConfigName, "Type");
                    if (nServerType == (long)NFServer_def.NF_SERVER_TYPES.NF_ST_GAME)
                    {
                        Int64  nPort       = mxElementInfoModule.QueryPropertyInt(strConfigName, "Port");
                        Int64  nMaxConnect = mxElementInfoModule.QueryPropertyInt(strConfigName, "MaxOnline");
                        Int64  nCpus       = mxElementInfoModule.QueryPropertyInt(strConfigName, "CpuCount");
                        Int64  nAreaID     = mxElementInfoModule.QueryPropertyInt(strConfigName, "AreaID");
                        string strName     = mxElementInfoModule.QueryPropertyString(strConfigName, "Name");
                        string strIP       = mxElementInfoModule.QueryPropertyString(strConfigName, "IP");

                        ConnectObjectData xConnectObjectData = new ConnectObjectData();

                        xConnectObjectData.fMaxReconnectTime = 10.0f;//重连时间
                        //xConnectObjectData.xNextTriggerTime = new DateTime();//下次重连时间

                        xConnectObjectData.nServerID    = nServerID;
                        xConnectObjectData.meServerType = (NFServer_def.NF_SERVER_TYPES)nServerType;
                        xConnectObjectData.mstrIP       = strIP;
                        xConnectObjectData.mstrDns      = strIP;
                        xConnectObjectData.mstrAuth     = "";

                        xConnectObjectData.mnPort   = nPort;
                        xConnectObjectData.mnAreaID = nAreaID;
                        //public NFNetModule xNetModule;
                        xConnectObjectData.eState = NFClusterClientModule.ClusterClientState.ADDING;

                        //GetNetHandler().RegisterEventCallback(OnSocketEvent);
                        //GetNetHandler().RegisterPackCallback(-1, OnRecivePack);

                        AddNetInfo(xConnectObjectData);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override void AfterInit()
        {
            mxEventProcessModule = GetMng().GetModule<NFCEventModule>();
            mxKernelModule = GetMng().GetModule<NFIKernelModule>();
            mxLogicClassModule = GetMng().GetModule<NFILogicClassModule>();
            mxElementInfoModule = GetMng().GetModule<NFIElementModule>();

            System.Diagnostics.Debug.Assert(null != mxEventProcessModule);
            System.Diagnostics.Debug.Assert(null != mxKernelModule);
            System.Diagnostics.Debug.Assert(null != mxLogicClassModule);
            System.Diagnostics.Debug.Assert(null != mxElementInfoModule);

            NFILogicClass xLogicClass = mxLogicClassModule.GetElement("Server");
            if (xLogicClass != null)
            {
                List<string> xNameList = xLogicClass.GetConfigNameList();

                foreach (string strConfigName in xNameList)
                {
                    long nServerID = mxElementInfoModule.QueryPropertyInt(strConfigName, "ServerID");
                    long nServerType = mxElementInfoModule.QueryPropertyInt(strConfigName, "Type");
                    if (nServerType == (long)NFServer_def.NF_SERVER_TYPES.NF_ST_WORLD)
                    {
                        Int64 nPort = mxElementInfoModule.QueryPropertyInt(strConfigName, "Port");
                        Int64 nMaxConnect = mxElementInfoModule.QueryPropertyInt(strConfigName, "MaxOnline");
                        Int64 nCpus = mxElementInfoModule.QueryPropertyInt(strConfigName, "CpuCount");
                        Int64 nAreaID = mxElementInfoModule.QueryPropertyInt(strConfigName, "AreaID");
                        string strName = mxElementInfoModule.QueryPropertyString(strConfigName, "Name");
                        string strIP = mxElementInfoModule.QueryPropertyString(strConfigName, "IP");

                        ConnectObjectData xConnectObjectData = new ConnectObjectData();

                        xConnectObjectData.fMaxReconnectTime = 10.0f;//重连时间
                        //xConnectObjectData.xNextTriggerTime = new DateTime();//下次重连时间

                        xConnectObjectData.nServerID = nServerID;
                        xConnectObjectData.meServerType = (NFServer_def.NF_SERVER_TYPES)nServerType;
                        xConnectObjectData.mstrIP = strIP;
                        xConnectObjectData.mstrDns = strIP;
                        xConnectObjectData.mstrAuth = "";

                        xConnectObjectData.mnPort = nPort;
                        xConnectObjectData.mnAreaID = nAreaID;
                        //public NFNetModule xNetModule;
                        xConnectObjectData.eState = NFClusterClientModule.ClusterClientState.ADDING;

                        //GetNetHandler().RegisterEventCallback(OnSocketEvent);
                        //GetNetHandler().RegisterPackCallback(-1, OnRecivePack);

                        AddNetInfo(xConnectObjectData);
                    }
                }
            }
        }
Exemplo n.º 3
0
        void RemoveServerWeightData(ConnectObjectData xInfo)
        {
            for (int j = 0; j < (int)NFCMachineNode.EConstDefine.EConstDefine_DefaultWeith; ++j)
            {
                NFCMachineNode vNode = new NFCMachineNode(j);

                vNode.nMachineID = xInfo.nServerID;
                vNode.strIP      = xInfo.mstrIP;
                vNode.nPort      = xInfo.mnPort;
                vNode.nWeight    = (long)NFCMachineNode.EConstDefine.EConstDefine_DefaultWeith;
                mxConsistentHash.Erase(vNode);
            }
        }
Exemplo n.º 4
0
        void RemoveServerWeightData(ConnectObjectData xInfo)
        {
            for (int j = 0; j < (int)NFCMachineNode.EConstDefine.EConstDefine_DefaultWeith; ++j)
            {
                NFCMachineNode vNode = new NFCMachineNode(j);

                vNode.nMachineID = xInfo.nServerID;
                vNode.strIP = xInfo.mstrIP;
                vNode.nPort = xInfo.mnPort;
                vNode.nWeight = (long)NFCMachineNode.EConstDefine.EConstDefine_DefaultWeith;
                mxConsistentHash.Erase(vNode);
            }
        }
Exemplo n.º 5
0
        public void AddNetInfo(ConnectObjectData xData)
        {
            if (null == xData)
            {
                return;
            }

            if (mxNetDic.ContainsKey(xData.nServerID))
            {
                //或者,更新ip等
                return;
            }

            xData.eState = ClusterClientState.ADDING;
            mxNetDic.Add(xData.nServerID, xData);
        }
Exemplo n.º 6
0
        public void AddNetInfo(ConnectObjectData xData)
        {
            if(null == xData)
            {
                return;
            }

            if (mxNetDic.ContainsKey(xData.nServerID))
            {
                //或者,更新ip等
                return;
            }

            xData.eState = ClusterClientState.ADDING;
            mxNetDic.Add(xData.nServerID, xData);
        }