mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-15 00:15:15 +08:00
Add deflate compressions options to MqttClientWebSocketOptionsBuilder (#2127)
* fix: unused tryPrivate parameter in WithTryPrivate * Fix wrong usage of try private * feat: add option to provide deflate compression options to WebSocketOptionsBuilder --------- Co-authored-by: christian <6939810+chkr1011@users.noreply.github.com>
This commit is contained in:
@@ -200,6 +200,9 @@ namespace MQTTnet.Implementations
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_options.DangerousDeflateOptions != null)
|
||||||
|
clientWebSocket.Options.DangerousDeflateOptions = _options.DangerousDeflateOptions;
|
||||||
|
|
||||||
// Only set the value if it is actually true. This property is not supported on all platforms
|
// Only set the value if it is actually true. This property is not supported on all platforms
|
||||||
// and will throw a _PlatformNotSupported_ (i.e. WASM) exception when being used regardless of the actual value.
|
// and will throw a _PlatformNotSupported_ (i.e. WASM) exception when being used regardless of the actual value.
|
||||||
if (_options.UseDefaultCredentials)
|
if (_options.UseDefaultCredentials)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace MQTTnet;
|
|||||||
public sealed class MqttClientWebSocketOptions : IMqttClientChannelOptions
|
public sealed class MqttClientWebSocketOptions : IMqttClientChannelOptions
|
||||||
{
|
{
|
||||||
public CookieContainer CookieContainer { get; set; }
|
public CookieContainer CookieContainer { get; set; }
|
||||||
|
public WebSocketDeflateOptions DangerousDeflateOptions { get; set; }
|
||||||
|
|
||||||
public ICredentials Credentials { get; set; }
|
public ICredentials Credentials { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Net.WebSockets;
|
||||||
|
|
||||||
namespace MQTTnet;
|
namespace MQTTnet;
|
||||||
|
|
||||||
@@ -23,6 +24,18 @@ public sealed class MqttClientWebSocketOptionsBuilder
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Allows the client to negotiate deflate compression on every message, by using the permessage-deflate WebSocket extension.
|
||||||
|
/// This adds the Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits header.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dangerousDeflateOptions"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public MqttClientWebSocketOptionsBuilder WithDangerousDeflateOptions(WebSocketDeflateOptions dangerousDeflateOptions)
|
||||||
|
{
|
||||||
|
_webSocketOptions.DangerousDeflateOptions = dangerousDeflateOptions;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public MqttClientWebSocketOptionsBuilder WithCookieContainer(ICredentials credentials)
|
public MqttClientWebSocketOptionsBuilder WithCookieContainer(ICredentials credentials)
|
||||||
{
|
{
|
||||||
_webSocketOptions.Credentials = credentials;
|
_webSocketOptions.Credentials = credentials;
|
||||||
|
|||||||
Reference in New Issue
Block a user