Add proxy settings for WebSocket connections for .NET 451 and 461

This commit is contained in:
Marius Ruginosu
2018-07-18 10:51:45 +03:00
parent 23ae8ab3b5
commit fa34908d82
4 changed files with 73 additions and 1 deletions
@@ -76,6 +76,29 @@ namespace MQTTnet.Client
return this;
}
#if NET452 || NET461
public MqttClientOptionsBuilder WithProxy(string address, string username = null, string password = null, string domain = null, bool bypassOnLocal = false, string[] bypassList = null)
{
if (_webSocketOptions == null)
{
throw new InvalidOperationException("A WebSocket channel must be set if MqttClientWebSocketProxy is configured.");
}
_webSocketOptions.MqttClientWebSocketProxy = new MqttClientWebSocketProxyOptions
{
Address = address,
Username = username,
Password = password,
Domain = domain,
BypassOnLocal = bypassOnLocal,
BypassList = bypassList
};
return this;
}
#endif
public MqttClientOptionsBuilder WithWebSocketServer(string uri)
{
_webSocketOptions = new MqttClientWebSocketOptions