#region << 版 本 注 释 >>

/*--------------------------------------------------------------------
* 版权所有 (c) 2025 WenJY 保留所有权利。
* CLR版本：4.0.30319.42000
* 机器名称：Mr.Wen's MacBook Pro
* 命名空间：Sln.Iot.CFX.CoreCommunications
* 唯一标识：8D142D51-E08D-42FC-8C59-4551A1B36306
*
* 创建者：WenJY
* 电子邮箱：
* 创建时间：2025-10-24 14:58:25
* 版本：V1.0.0
* 描述：
*
*--------------------------------------------------------------------
* 修改人：
* 时间：
* 修改说明：
*
* 版本：V1.0.0
*--------------------------------------------------------------------*/

#endregion << 版 本 注 释 >>

using CFX;
using CFX.Structures;
using Sln.Iot.Serilog;

namespace Sln.Iot.CFX.RequestReceived;

/// <summary>
/// 5.4.1.1-端点在位查询请求
/// AreYouThereRequest/Response
/// </summary>
public class BaseAreYouThereRequestReceived
{
    /// <summary>
    /// 数据处理
    /// </summary>
    /// <param name="request"></param>
    /// <param name="response"></param>
    public void Handle(AreYouThereRequest request, out CFXMessage response)
    {
        //业务逻辑
        try
        {
            response = SubHandle(request);
        }
        catch (Exception e)
        {
            //无法响应时上传NotSupportedResponse
            response = new NotSupportedResponse()
            {
                RequestResult = new RequestResult()
                {
                    Result = StatusResult.Failed,
                    ResultCode = 0,
                    Message = e.Message
                }
            };
            SerilogHelper.Instance.Error("端点在位查询请求数据解析异常", e);
        }
    }

    /// <summary>
    /// 子类重写处理
    /// </summary>
    /// <param name="request"></param>
    /// <returns></returns>
    public virtual CFXMessage SubHandle(AreYouThereRequest request)
    {
        CFXMessage response = new AreYouThereResponse()
        {
            Result = new RequestResult()
            {
                Result = StatusResult.Success,
                ResultCode = 0,
                Message = "",
            },

            CFXHandle = request.CFXHandle,
            RequestNetworkUri = "amqp://127.0.0.1:1235",
            RequestTargetAddress = "amqp://127.0.0.1:8888"
        };

        return response;
    }

}