Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
build:

runs-on: windows-2019
runs-on: windows-2025

steps:
- uses: actions/checkout@v2
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "CodeQL"

on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master ]
schedule:
- cron: '23 12 * * 1'

jobs:
analyze:
name: Analyze
runs-on: windows-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'csharp' ]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
queries: security-and-quality

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2

- name: Setup NuGet
uses: nuget/setup-nuget@v1
with:
nuget-version: 'latest'

- name: Restore dependencies
run: nuget restore pusher-dotnet-client.sln

- name: Build
run: msbuild /p:deterministic=true /p:msbuildArchitecture=x64 /p:configuration=Release pusher-dotnet-client.sln

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
build:

runs-on: windows-2019
runs-on: windows-2025

steps:
- uses: actions/checkout@v2
Expand Down
12 changes: 6 additions & 6 deletions AuthHost/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="Port" value="8888" />
</appSettings>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="Port" value="9000" />
</appSettings>
</configuration>
47 changes: 46 additions & 1 deletion AuthHost/AuthModule.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Threading.Tasks;
using Nancy;
using Newtonsoft.Json;
using PusherClient;
using PusherClient.Tests.Utilities;
using PusherServer;
Expand Down Expand Up @@ -60,6 +61,50 @@ public AuthModule()

return authData;
};

// Add routes that ExampleApplication expects
Post["/pusher/auth"] = _ =>
{
Console.WriteLine($"Processing auth request for '{Request.Form.channel_name}' channel, for socket ID '{Request.Form.socket_id}'");

string channelName = Request.Form.channel_name;
string socketId = Request.Form.socket_id;

string authData = null;

if (Channel.GetChannelType(channelName) == ChannelTypes.Presence)
{
var channelData = new PresenceChannelData
{
user_id = socketId,
user_info = new { Name = "DefaultUser" }
};

authData = provider.Authenticate(channelName, socketId, channelData).ToJson();
}
else
{
authData = provider.Authenticate(channelName, socketId).ToJson();
}

return authData;
};

Post["/pusher/auth-user"] = _ =>
{
Console.WriteLine($"Processing user auth request for socket ID '{Request.Form.socket_id}'");

string socketId = Request.Form.socket_id;

// For user authentication, return a simple user auth response
var userAuthResponse = new
{
auth = $"{PusherApplicationKey}:{socketId}",
user_data = JsonConvert.SerializeObject(new { id = socketId, name = "DefaultUser" })
};

return JsonConvert.SerializeObject(userAuthResponse);
};
}

private async Task SendSecretMessageAsync()
Expand All @@ -82,4 +127,4 @@ private async Task SendSecretMessageAsync()
Console.WriteLine(secretMessage);
}
}
}
}
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Changelog
# Changelog

##
* [CHANGED] Force TLS 1.2 by default.

## 2.3.0-beta
* [Added] Introduce user features
Expand Down
15 changes: 9 additions & 6 deletions PusherClient/Connection.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Security.Authentication;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
Expand Down Expand Up @@ -50,7 +51,8 @@ public async Task ConnectAsync()

ChangeState(ConnectionState.Connecting);

_websocket = new WebSocket(_url)
_websocket = new WebSocket(_url, "", null, null, "",
"", WebSocketVersion.None, null, SslProtocols.Tls12)
{
EnableAutoSendPing = true,
AutoSendPingInterval = 1
Expand Down Expand Up @@ -210,13 +212,13 @@ private void ProcessPusherEvent(string eventName, string rawJson, Dictionary<str
{
messageData = (string)message["data"];
}

switch (eventName)
{
case Constants.CONNECTION_ESTABLISHED:
ParseConnectionEstablished(messageData);
break;

case Constants.PUSHER_SIGNIN_SUCCESS:
case Constants.PUSHER_WATCHLIST_EVENT:
EmitEvent(eventName, rawJson, message);
Expand Down Expand Up @@ -244,7 +246,7 @@ private bool ProcessPusherChannelEvent(string eventName, string channelName, str
case Constants.CHANNEL_MEMBER_REMOVED:
_pusher.RemoveMember(channelName, messageData);
break;

case Constants.CHANNEL_SUBSCRIPTION_COUNT:
_pusher.SubscriberCount(channelName, messageData);
break;
Expand Down Expand Up @@ -292,7 +294,7 @@ private void WebsocketMessageReceived(object sender, MessageReceivedEventArgs e)
* "event": "pusher:connection_established",
* "data": "{\"socket_id\":\"131160.155806628\"}"
* }
*
*
* {
* "event": "pusher_internal:subscription_succeeded",
* "data": "{\"presence\":{\"count\":1,\"ids\":[\"131160.155806628\"],\"hash\":{\"131160.155806628\":{\"name\":\"user-1\"}}}}",
Expand Down Expand Up @@ -470,7 +472,8 @@ private void DisposeWebsocket()
private void RecreateWebSocket()
{
DisposeWebsocket();
_websocket = new WebSocket(_url)
_websocket = new WebSocket(_url, "", null, null, "",
"", WebSocketVersion.None, null, SslProtocols.Tls12)
{
EnableAutoSendPing = true,
AutoSendPingInterval = 1
Expand Down
6 changes: 3 additions & 3 deletions Root.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<PackageDescription>The .NET library for interacting with the Pusher WebSocket API. Register at http://pusher.com</PackageDescription>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>icon-128.png</PackageIcon>
<Version>2.3.0-beta</Version>
<AssemblyVersion>2.3.0.0</AssemblyVersion>
<FileVersion>2.3.0.0</FileVersion>
<Version></Version>
<AssemblyVersion>.0</AssemblyVersion>
<FileVersion>.0</FileVersion>
</PropertyGroup>

</Project>