/// <summary>
 /// 回复侦测
 /// </summary>
 /// <param name="data"></param>
 /// <param name="rsp"></param>
 private void RspDetect(byte[] data, SocketRsp rsp)
 {
     if (rsp.Rsp != null)
     {
         rsp.Rsp.Send(rspConst);
     }
     else
     {
         uDP.Send(rsp.Address, rsp.Port, rspConst);
     }
 }
        /// <summary>
        /// 回复订阅信息
        /// </summary>
        /// <param name="data"></param>
        /// <param name="rsp"></param>
        private void RspSubscribe(byte[] data, SocketRsp rsp)
        {
            if (rsp.Rsp != null)
            {
                rsp.Rsp.Send(rspConst);
            }
            else
            {
                uDP.Send(rsp.Address, rsp.Port, rspConst);
            }
            //接收订阅
            var         msg     = DataPack.UnPackSubscribeMsg(data);
            AddressInfo address = new AddressInfo();

            address.Reset(msg.Address);
            SubscribeList.Subscribe.AddAddress(msg.TopicName, new AddressInfo[] { address });
        }
        /// <summary>
        /// 返回订阅地址
        /// </summary>
        /// <param name="data"></param>
        private void CopyAddress(byte[] data, SocketRsp rsp)
        {
            string topic = Encoding.Default.GetString(data, 1, data.Length - 1);
            var    addrs = SubscribeList.Subscribe.GetAddresses(topic);
            var    bytes = DataPack.PackCopyRspTopic(addrs);

            if (bytes == null)
            {
                bytes = Encoding.Default.GetBytes(" ");
            }
            if (rsp.Rsp != null)
            {
                rsp.Rsp.Send(bytes);
            }
            else
            {
                uDP.Send(rsp.Address, rsp.Port, bytes);
            }
        }
        private void Process(byte[] data, SocketRsp rsp)
        {
            switch (data[0])
            {
            case 2:
                CopyAddress(data, rsp);
                break;

            case 3:
                RspSubscribe(data, rsp);
                break;

            case 8:
                RspDetect(data, rsp);
                break;

            case 0:
                ProcessTopic(data);
                break;
            }
        }
 private void UDP_UDPCall(System.Buffers.ArrayPool <byte> pool, byte[] data, int len, SocketRsp rsp)
 {
     byte[] tmp = new byte[len];
     Array.Copy(data, 0, tmp, 0, tmp.Length);
     pool.Return(data);
     Process(tmp, rsp);
 }