using Microsoft.AspNetCore.Http;
using MQTTnet;
using System;
using System.Collections.Generic;
using System.Text;

namespace Edge.Core.UniversalApi
{
    public class RequestContext
    {
        public RequestContext(object rawRequest)
        {
            this.RawRequest = rawRequest;
            if (rawRequest is HttpRequest httpRequest)
            {
                this.ClientIdentity = httpRequest.HttpContext.Connection.RemoteIpAddress + ":" + httpRequest.HttpContext.Connection.RemotePort;
            }
            //else if (rawRequest is MqttApplicationMessageReceivedEventArgs mqttRequest)
            //{
            //    var debug = mqttRequest.ApplicationMessage.UserProperties;
            //    this.ClientIdentity = mqttRequest.ClientId;
            //}
        }

        public object RawRequest { get; private set; }

        public string ClientIdentity { get; private set; }
    }
}
