Skip to content

Added EnabledSslProtocols option in the PusherOptions #154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions PusherClient/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ public async Task ConnectAsync()

ChangeState(ConnectionState.Connecting);

_websocket = new WebSocket(_url)
{
EnableAutoSendPing = true,
AutoSendPingInterval = 1
};
CreateNewWebSocket();

await Task.Run(() =>
{
Expand Down Expand Up @@ -467,16 +463,31 @@ private void DisposeWebsocket()
ChangeState(ConnectionState.Disconnected);
}

private void RecreateWebSocket()
private void CreateNewWebSocket()
{
DisposeWebsocket();
_websocket = new WebSocket(_url)
_websocket = new WebSocket(_url,
"", //string subProtocol = "",
null, //List<KeyValuePair<string, string>> cookies = null,
null, //List<KeyValuePair<string, string>> customHeaderItems = null,
"", //string userAgent = "",
"", //string origin = "",
WebSocketVersion.None, // WebSocketVersion version = WebSocketVersion.None,
null, // EndPoint httpConnectProxy = null,
_pusher.PusherOptions.EnabledSslProtocols,
0) // int receiveBufferSize = 0)
{
EnableAutoSendPing = true,
AutoSendPingInterval = 1
};
}


private void RecreateWebSocket()
{
DisposeWebsocket();
CreateNewWebSocket();
}

private void ParseError(JToken jToken)
{
JToken message = jToken.SelectToken("message");
Expand Down
7 changes: 7 additions & 0 deletions PusherClient/PusherOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Security.Authentication;

namespace PusherClient
{
Expand Down Expand Up @@ -104,6 +105,12 @@ public string Host
/// </summary>
public TimeSpan ClientTimeout { get; set; } = TimeSpan.FromSeconds(30);


/// <summary>
/// Gets or sets the ssl security protocol to communicate. The default value is SslProtocols.None.
/// </summary>
public SslProtocols EnabledSslProtocols { get; set; } = SslProtocols.None;

/// <summary>
/// Gets or sets the <see cref="ITraceLogger"/> to use for tracing debug messages.
/// </summary>
Expand Down