Exemple #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;
            };
        }
Exemple #2
0
        public void Stop()
        {
            if (mDBConnect != null)
            {
                System.Windows.Forms.MessageBox.Show("数据服务器关闭!");
                mDBConnect.CloseConnect();
                mDBConnect = null;
            }

            mTcpSrv.ReceiveData          -= RPC.RPCNetworkMgr.Instance.ServerReceiveData;
            mTcpSrv.CloseConnect         -= this.ServerDisConnected;
            mRegisterConnect.ReceiveData -= RPC.RPCNetworkMgr.Instance.ClientReceiveData;
            mRegisterConnect.NewConnect  -= this.OnRegisterConnected;

            mRegisterConnect.Close();
            mTcpSrv.Close();
            System.Diagnostics.Debug.WriteLine("数据服务器关闭");
            mLinkState = LogServerState.None;

            Log.FileLog.Instance.End();
        }
Exemple #3
0
        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;
        }