Ejemplo n.º 1
0
        void OnRegisterConnected(Iocp.TcpClient pClient, byte[] pData, int nLength)
        {
            if (nLength == 0)
            {
                return;
            }
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            //System.String[] ips = Iocp.TcpServer.GetHostIpAddress();
            //mParameter.ListenIP = SelectLogServerIP(ips);

            H_RPCRoot.smInstance.HGet_RegServer(pkg).RegLogServer(pkg, mParameter.ListenIP, mParameter.ListenPort, mParameter.ServerId);
            pkg.WaitDoCommand(mRegisterConnect, RPC.CommandTargetType.DefaultType, new System.Diagnostics.StackTrace(1, true)).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool bTimeOut)
            {
                System.Diagnostics.Debug.WriteLine("数据服务器({0})启动并且注册成功,可以等待连接服务器接入了", mParameter.ServerId);

                if (mLinkState != LogServerState.Working)
                {
                    if (false == mTcpSrv.Open(Iocp.TcpOption.ForComServer, mParameter.ListenPort))
                    {
                        return;
                    }
                }

                mLinkState = LogServerState.Working;
            };
        }
Ejemplo n.º 2
0
        void OnRegisterConnected(Iocp.TcpClient pClient, byte[] pData, int nLength)
        {
            if (nLength == 0)
            {
                return;
            }
            RPC.PackageWriter pkg = new RPC.PackageWriter();

            H_RPCRoot.smInstance.HGet_RegServer(pkg).RegComServer(pkg, mParameter.ListenIP, mParameter.ServerId);
            pkg.WaitDoCommand(mRegisterConnect, RPC.CommandTargetType.DefaultType, new System.Diagnostics.StackTrace(1, true)).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool bTimeOut)
            {
                System.Diagnostics.Debug.WriteLine("公共信息通讯服务器({0})启动并且注册成功,可以等待位面服务器接入了", mParameter.ServerId);
                UInt16 listenPort = 0;
                _io.Read(out listenPort);
                mParameter.ListenPort = listenPort;

                if (mLinkState != ComServerState.Working)
                {
                    if (false == mTcpSrv.Open(Iocp.TcpOption.ForComServer, mParameter.ListenPort))
                    {
                        return;
                    }
                }

                mLinkState = ComServerState.Working;
            };
        }
Ejemplo n.º 3
0
 void OnFindPathServerConnected(Iocp.TcpClient pClient, byte[] pData, int nLength)
 {
     if (nLength == 0)
     {
         return;
     }
 }
Ejemplo n.º 4
0
        void OnRegisterConnected(Iocp.TcpClient pClient, byte[] pData, int nLength)
        {
            if (nLength == 0)
            {
                return;
            }
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            //System.String[] ips = Iocp.TcpServer.GetHostIpAddress();
            //mParameter.ListenIP = SelectDataServerIP(ips);

            H_RPCRoot.smInstance.HGet_RegServer(pkg).RegPlanesServer(pkg, mParameter.ServerId);
            pkg.WaitDoCommand(mRegisterConnect, RPC.CommandTargetType.DefaultType, null).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool bTimeOut)
            {
                UInt16 port;
                _io.Read(out port);
                mParameter.ListenPort = port;

                System.Diagnostics.Debug.WriteLine("位面服务器({0})启动并且注册成功,可以等待连接服务器接入了", mParameter.ServerId);

                mLinkState = PlanesServerState.WaitDataServer;

                //ConnectDataServer();

                //ConnectPathFindServer();
            };
        }
Ejemplo n.º 5
0
        public void _SyncDoCommand(Iocp.TcpClient cltConn, int timeout)
        {
            if (RPCManager == null)
            {
                RPCManager = RPCNetworkMgr.Instance;
            }
            PkgType = PackageType.PKGT_SendAndWait;
            RPCWaitHandle handle = RPCManager.NewWaitHandle(null);

            SendBuffer(cltConn);
            while (true)
            {
                cltConn.Update();
                if (null == RPCManager.GetWaitHandle(handle.CallID))
                {
                    break;
                }

                System.Threading.Thread.Sleep(1);
            }
        }
Ejemplo n.º 6
0
 public void ClientReceiveData(Iocp.TcpClient pClient, byte[] pData, int nLength)
 {
     ReceiveData(pClient, pData, nLength);
 }
Ejemplo n.º 7
0
        //yzb
        void OnDataServerConnected(Iocp.TcpClient pClient, byte[] pData, int nLength)
        {
            if (nLength == 0)
            {
                return;
            }
            if (mLinkState != PlanesServerState.Working)
            {
                if (false == mTcpSrv.Open(Iocp.TcpOption.ForPlanesServer, mParameter.ListenPort))
                {
                    return;
                }
                System.Diagnostics.Debug.WriteLine("DateServer连接成功,PlanesServer开始接受GateServer接入");
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("PlanesServer与DataServer断线后重连接成功");
            }
            mLinkState = PlanesServerState.Working;

            //注册到data服务器
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            H_RPCRoot.smInstance.HGet_DataServer(pkg).RegPlanesServer(pkg, mParameter.ListenIP, mParameter.ListenPort, mParameter.ServerId);

            pkg.WaitDoCommand(mDataConnect, RPC.CommandTargetType.DefaultType, null).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool bTimeOut)
            {
                RPC.DataReader dr;
                _io.Read(out dr);

                //读取区服务器信息
                int liCount = 0;
                dr.Read(out liCount);
                for (int i = 0; i < liCount; i++)
                {
                    ushort lAreaId   = 0;
                    string lAreaName = "";
                    dr.Read(out lAreaId);
                    dr.Read(out lAreaName);

                    CSCommon.Data.PlanesData planesData = new CSCommon.Data.PlanesData();
                    planesData.PlanesId   = lAreaId;    //区ID
                    planesData.PlanesName = lAreaName;  //区名
                    Planes.MapInstanceManager.Instance.PlanesManager.GetPlanesInstance(planesData);
                }

                //地图信息
                liCount = 0;
                dr.Read(out liCount);
                for (int i = 0; i < liCount; i++)
                {
                    int liAreaId = 0;
                    dr.Read(out liAreaId);
                    int liMapId = 0;
                    dr.Read(out liMapId);

                    //启动地图
                    Planes.PlanesInstance planes;
                    if (Planes.MapInstanceManager.Instance.PlanesManager.AllPlanesInstance.TryGetValue((ulong)liAreaId, out planes))
                    {
                        Planes.MapInstance map = null;
                        map = planes.GetGlobalMap((ushort)liMapId);
                        if (map == null)
                        {
                            map = Planes.MapInstanceManager.Instance.CreateMapInstance(planes, 0, (ushort)liMapId, null);
                            if (map == null)
                            {
                                map = Planes.MapInstanceManager.Instance.GetDefaultMapInstance(planes);
                            }
                            planes.AddGlobalMap((ushort)liMapId, map);
                        }
                    }
                }
            };

            //同步国战信息
            PlanesCountryWar.CCountryWarMgr.Instance.Start();
        }
Ejemplo n.º 8
0
 void OnComServerConnected(Iocp.TcpClient pClient, byte[] pData, int nLength)
 {
 }