void ConnectComServer() { Instance = this; RPC.PackageWriter pkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_RegServer(pkg).GetComServer(pkg); pkg.WaitDoCommand(mRegisterConnect, RPC.CommandTargetType.DefaultType, new System.Diagnostics.StackTrace(1, true)).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool bTimeOut) { RPC.DataReader dr; _io.Read(out dr); string gsIpAddress = ""; UInt16 gsPort = 0; if (dr.Length > 0) { dr.Read(out gsIpAddress); dr.Read(out gsPort); } if (gsIpAddress != "" && gsPort != 0) { if (mLinkState == PlanesServerState.WaitRegServer) { mComConnect.Connect(gsIpAddress, gsPort); System.Diagnostics.Debug.WriteLine("PlanesServer成功连接RegServer,尝试连接DataServer:" + gsIpAddress + ":" + gsPort); } else { mComConnect.Connect(gsIpAddress, gsPort); System.Diagnostics.Debug.WriteLine("PlanesServer断线,重新从RegServer获得地址,尝试连接DataServer:" + gsIpAddress + ":" + gsPort); } } }; }
public void Start(IComServerParameter parameter) { Stop(); mParameter = parameter; mTcpSrv.ReceiveData += RPC.RPCNetworkMgr.Instance.ServerReceiveData; mRegisterConnect.ReceiveData += RPC.RPCNetworkMgr.Instance.ClientReceiveData; mRegisterConnect.NewConnect += this.OnRegisterConnected; ServerFrame.DB.AsyncExecuteThreadManager.Instance.InitManager(2); ServerFrame.DB.AsyncExecuteThreadManager.Instance.StartThread(); mRegisterConnect.Connect(parameter.RegServerIP, parameter.RegServerPort); mLinkState = ComServerState.WaitRegServer; this.UserRoleManager.DBConnect.OpenConnect(); Log.FileLog.Instance.Begin("ComServer.log", false); Log.Log.Server.Print("ComServer Start!"); Log.FileLog.Instance.Flush(); IServer.LoadAllTemplateData(ServerCommon.ServerConfig.Instance.TemplatePath); ServerCommon.TemplateTableLoader.LoadTable(ServerCommon.ServerConfig.Instance.TablePath); this.UserRoleManager.DownloadPlanesData(); this.UserRoleManager.DownloadRankData(); this.UserRoleManager.RankInit(); Com.GuildManager.Instance.Init(); this.WolrdManager.Init(UserRoleManager.Planes.Values.ToArray()); }
public void Start(IPlanesServerParameter parameter) { //ServerFrame.Support.ClassInfoManager.Instance.Load(false); Log.FileLog.Instance.Begin("PlanesServer.log", false); Log.Log.Server.Print("PlanesServer 0!"); RPCPlanesServerSpecialRootImpl impl = new RPCPlanesServerSpecialRootImpl(); impl.mServer = this; RPC.RPCNetworkMgr.Instance.mPlanesServerSpecialRoot = impl; Log.Log.Server.Print("Register AICode Builder ===== ok!"); IServer.LoadAllTemplateData(ServerCommon.ServerConfig.Instance.TemplatePath); CSCommon.CSLog.LogFun = Log.Log.Common.Warning; ServerCommon.TemplateTableLoader.LoadTable(ServerCommon.ServerConfig.Instance.TablePath); Log.Log.Server.Print("PlanesServer 1!"); mParameter = parameter; mTcpSrv.ReceiveData += RPC.RPCNetworkMgr.Instance.ServerReceiveData; mTcpSrv.CloseConnect += this.GateServerDisConnected; mRegisterConnect.ReceiveData += RPC.RPCNetworkMgr.Instance.ClientReceiveData; mRegisterConnect.NewConnect += this.OnRegisterConnected; mDataConnect.ReceiveData += RPC.RPCNetworkMgr.Instance.ClientReceiveData; mDataConnect.NewConnect += this.OnDataServerConnected; mComConnect.ReceiveData += RPC.RPCNetworkMgr.Instance.ClientReceiveData; mComConnect.NewConnect += this.OnComServerConnected; //mPathFindConnect.ReceiveData += RPC.RPCNetworkMgr.Instance.ClientReceiveData; //mPathFindConnect.NewConnect += this.OnFindPathServerConnected; mRegisterConnect.Connect(parameter.RegServerIP, parameter.RegServerPort); mLinkState = PlanesServerState.WaitRegServer; Planes.GameLogicManager.Instance.Init(); //Log.FileLog.Instance.Begin("PlanesServer.log", false); Log.Log.Server.Print("PlanesServer Start ===== ok!"); Planes.LogicProcessorManager.Instance.StartProcessors(2); Log.Log.Server.Print("StartProcessors ===== ok!"); Log.FileLog.Instance.Flush(); ServerFrame.TimerManager.doLoop(5, EventDispacthAutoRemove); }
void ConnectDataServer() { Instance = this; RPC.PackageWriter pkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_RegServer(pkg).GetDataServer(pkg); pkg.WaitDoCommand(mRegisterConnect, RPC.CommandTargetType.DefaultType, null).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool bTimeOut) { RPC.DataReader dr; _io.Read(out dr); string gsIpAddress = ""; dr.Read(out gsIpAddress); UInt16 gsPort = 0; dr.Read(out gsPort); if (string.IsNullOrEmpty(gsIpAddress)) { return; } mDataConnect.Connect(gsIpAddress, gsPort); }; }
public void Start(ILogServerParameter parameter) { Stop(); Log.FileLog.Instance.Begin("LogServer.log", false); Log.Log.Common.Print("LogServer Start!"); Log.FileLog.Instance.Flush(); mDBConnect = new ServerFrame.DB.DBConnect(); mDBConnect.OpenConnect(); Log.Log.Common.Print("DBConnect OK!"); mParameter = parameter; mTcpSrv.ReceiveData += RPC.RPCNetworkMgr.Instance.ServerReceiveData; mTcpSrv.CloseConnect += this.ServerDisConnected; mRegisterConnect.ReceiveData += RPC.RPCNetworkMgr.Instance.ClientReceiveData; mRegisterConnect.NewConnect += this.OnRegisterConnected; mRegisterConnect.Connect(parameter.RegServerIP, parameter.RegServerPort); mLinkState = LogServerState.WaitRegServer; }
public void Start(IDataServerParameter parameter) { Stop(); mParameter = parameter; mDBLoaderConnect = new ServerFrame.DB.DBConnect(); mDBLoaderConnect.OpenConnect(); //ServerFrame.Support.ClassInfoManager.Instance.Load(false); Log.FileLog.Instance.Begin("DataServer.log", false); Log.Log.Server.Print("DataServer Start!"); Log.FileLog.Instance.Flush(); IServer.LoadAllTemplateData(ServerCommon.ServerConfig.Instance.TemplatePath); CSCommon.CSLog.LogFun = Log.Log.Common.Warning; ServerCommon.TemplateTableLoader.LoadTable(ServerCommon.ServerConfig.Instance.TablePath); //加载数据库中的静态配置信息 CSCommon.Data.CDbConfig.LoadDbConfig(mDBLoaderConnect); //国战服务初始化 CountryWar.CCountryWarMgr.Instance.Start(mDBLoaderConnect); Thread.AccountLoginThread.Instance.StartThread(); Thread.PlayerEnterThread.Instance.StartThread(); Thread.DBConnectManager.Instance.StartThreadPool(2); AsyncExecuteThreadManager.Instance.InitManager(1); AsyncExecuteThreadManager.Instance.StartThread(); //mChargeManger = new Data.ChargeManager(); mPlanesMgr = new Data.PlanesMgr(this); Log.Log.Server.Print("DBConnect OK!"); mTcpSrv.ReceiveData += RPC.RPCNetworkMgr.Instance.ServerReceiveData; mTcpSrv.CloseConnect += this.ServerDisConnected; mRegisterConnect.ReceiveData += RPC.RPCNetworkMgr.Instance.ClientReceiveData; mRegisterConnect.NewConnect += this.OnRegisterConnected; mRegisterConnect.Connect(parameter.RegServerIP, parameter.RegServerPort); mLinkState = DataServerState.WaitRegServer; InitNamePool(); mPlayerManager.DownloadPlayerData(mDBLoaderConnect); /*int avgSize = 0; * Support.PerfCounter perf = new Support.PerfCounter(); * perf.Begin(); * for (int i = 0; i < 1000; i++) * { * RPC.DataWriter dw0 = new RPC.DataWriter(); * CSCommon.Data.ItemData item0 = new CSCommon.Data.ItemData(); * item0.ItemTemlateId = 2; * //item0.DangrousReInitData(); * RPC.DataWriter dw1 = new RPC.DataWriter(); * CSCommon.Data.ItemData item1 = new CSCommon.Data.ItemData(); * item1.ItemTemlateId = 2; * // item1.DangrousReInitData(); * dw0.Write(item0); * dw1.Write(item1); * * int compressSize = dw1.CompressWithTemplate(dw0); * dw1.UnCompressWithTemplate(dw0); * * avgSize += compressSize; * * RPC.DataWriter dw2 = new RPC.DataWriter(); * dw2.Write(item1); * bool isSame = dw1.IsSame(dw2); * } * Int64 time = perf.End(); * System.Diagnostics.Debug.WriteLine( "{0}:{1}" , avgSize / 1000, time);*/ //test /* * var start = ServerCommon.IServer.timeGetTime(); * * CSCommon.Data.RoleDetail rd = new CSCommon.Data.RoleDetail(); * CSCommon.Data.RoleDetail rd2 = new CSCommon.Data.RoleDetail(); * //var r = TestAutoCode(rd); * rd.BagSize = 155; * rd.BindRmb = 155; * rd.CreateTime = DateTime.Now; * rd.LocationX = 15211; * rd.LocationY = 15211; * rd.LocationZ = 15211; * rd.Rmb = 123; * rd.RoleExp = 333; * for (int i = 0; i < 10000; i++) * { * //var r = rd.GetSql(rd2); * var r = ServerFrame.DB.DBConnect.TestUpdateData("", rd, rd2); * } * var end = ServerCommon.IServer.timeGetTime() - start; * var t = end;*/ }