Added EndPoint RemoteEndPoint {get;} property to channel (#2111)

* Added EndPoint RemoteEndPoint{get;} property

* Reformat code

* Reformat code

---------

Co-authored-by: christian <6939810+chkr1011@users.noreply.github.com>
This commit is contained in:
老九
2024-12-02 11:52:24 +01:00
committed by GitHub
co-authored by christian
parent ef5b6c9b32
commit 8089c6bdbc
20 changed files with 91 additions and 55 deletions
@@ -61,21 +61,21 @@ public sealed class MqttConnectionContext : IMqttChannelAdapter
}
}
public string Endpoint
public EndPoint RemoteEndPoint
{
get
{
// mqtt over tcp
if (_connection.RemoteEndPoint != null)
{
return _connection.RemoteEndPoint.ToString();
return _connection.RemoteEndPoint;
}
// mqtt over websocket
var httpFeature = _connection.Features.Get<IHttpConnectionFeature>();
if (httpFeature?.RemoteIpAddress != null)
{
return new IPEndPoint(httpFeature.RemoteIpAddress, httpFeature.RemotePort).ToString();
return new IPEndPoint(httpFeature.RemoteIpAddress, httpFeature.RemotePort);
}
return null;