Pārlūkot izejas kodu

Use IConnectionEndPointFeature to get IMqttChannelAdapter.Endpoint in aspnetcore31

release/3.x.x
陈国伟 pirms 4 gadiem
vecāks
revīzija
c10145f743
1 mainītis faili ar 8 papildinājumiem un 1 dzēšanām
  1. +8
    -1
      Source/MQTTnet.AspnetCore/MqttConnectionContext.cs

+ 8
- 1
Source/MQTTnet.AspnetCore/MqttConnectionContext.cs Parādīt failu

@@ -25,7 +25,7 @@ namespace MQTTnet.AspNetCore
_input = Connection.Transport.Input;
_output = Connection.Transport.Output;
}
_reader = new SpanBasedMqttPacketBodyReader();
}

@@ -37,6 +37,13 @@ namespace MQTTnet.AspNetCore
{
get
{
#if NETCOREAPP3_1
var endpointFeature = Connection.Features.Get<Microsoft.AspNetCore.Connections.Features.IConnectionEndPointFeature>();
if (endpointFeature != null)
{
return endpointFeature.RemoteEndPoint.ToString();
}
#endif
var connection = Http?.HttpContext?.Connection;
if (connection == null)
{


Notiek ielāde…
Atcelt
Saglabāt