mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-26 08:02:59 +08:00
Add overload to allow passing custom request headers and cookies when connecting with WS
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using MQTTnet.Serializer;
|
using MQTTnet.Serializer;
|
||||||
|
|
||||||
namespace MQTTnet.Client
|
namespace MQTTnet.Client
|
||||||
@@ -102,6 +104,23 @@ namespace MQTTnet.Client
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MqttClientOptionsBuilder WithWebSocketServer(string uri, MqttClientOptionsBuilderWebSocketParameters parameters)
|
||||||
|
{
|
||||||
|
if(parameters == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(parameters));
|
||||||
|
}
|
||||||
|
|
||||||
|
_webSocketOptions = new MqttClientWebSocketOptions
|
||||||
|
{
|
||||||
|
Uri = uri,
|
||||||
|
RequestHeaders = parameters.RequestHeaders,
|
||||||
|
CookieContainer = parameters.CookierContainer
|
||||||
|
};
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public MqttClientOptionsBuilder WithTls(MqttClientOptionsBuilderTlsParameters parameters)
|
public MqttClientOptionsBuilder WithTls(MqttClientOptionsBuilderTlsParameters parameters)
|
||||||
{
|
{
|
||||||
_tlsParameters = parameters ?? throw new ArgumentNullException(nameof(parameters));
|
_tlsParameters = parameters ?? throw new ArgumentNullException(nameof(parameters));
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace MQTTnet.Client
|
||||||
|
{
|
||||||
|
public class MqttClientOptionsBuilderWebSocketParameters
|
||||||
|
{
|
||||||
|
public IDictionary<string, string> RequestHeaders { get; set; }
|
||||||
|
|
||||||
|
public CookieContainer CookierContainer { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user