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); } } }; }
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); }; }