Skip to content
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

add socketio support when generating client access uri #46942

Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions sdk/webpubsub/Azure.Messaging.WebPubSub/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 1.5.0-beta.1 (Unreleased)

### Features Added
- Added support for SocketIO when generating ClientAccessURI

### Breaking Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ public enum WebPubSubClientProtocol
/// MQTT client protocol, whose access endpoint starts with "/clients/mqtt".
/// </summary>
Mqtt,

/// <summary>
/// SocketIO client protocol, whose access endpoint starts with "/clients/socketio".
/// </summary>
SocketIO,
}
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ private string GenerateTokenFromAzureKeyCredential(DateTimeOffset expiresAt, Web
{
WebPubSubClientProtocol.Default => $"client/hubs/{_hub}",
WebPubSubClientProtocol.Mqtt => $"clients/mqtt/hubs/{_hub}",
WebPubSubClientProtocol.SocketIO => $"clients/socketio/hubs/{_hub}",
_ => throw new ArgumentOutOfRangeException(nameof(clientProtocol))
};

Expand All @@ -407,6 +408,7 @@ private async Task<string> GetClientAccessTokenCore(
{
WebPubSubClientProtocol.Default => "default",
WebPubSubClientProtocol.Mqtt => "mqtt",
WebPubSubClientProtocol.SocketIO => "socketio",
_ => throw new ArgumentOutOfRangeException(nameof(clientAccess))
};
if (_tokenCredential != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class WebPubSubGenerateUriTests

[TestCase(WebPubSubClientProtocol.Default, "/client")]
[TestCase(WebPubSubClientProtocol.Mqtt, "/clients/mqtt")]
[TestCase(WebPubSubClientProtocol.SocketIO, "/clients/socketio")]
public async Task GetClientAccessUri_AccessKey_Test(WebPubSubClientProtocol clientType, string clientUriPrefix)
{
var serviceClient = new WebPubSubServiceClient(string.Format("Endpoint=http://localhost;Port=8080;AccessKey={0};Version=1.0;", FakeAccessKey), "hub");
Expand All @@ -38,6 +39,7 @@ public async Task GetClientAccessUri_AccessKey_Test(WebPubSubClientProtocol clie

[TestCase(WebPubSubClientProtocol.Default, "/client", "default")]
[TestCase(WebPubSubClientProtocol.Mqtt, "/clients/mqtt", "mqtt")]
[TestCase(WebPubSubClientProtocol.SocketIO, "/clients/socketio", "socketio")]
public async Task GetClientAccessUri_MicrosoftEntraId_DefaultClient_Test(WebPubSubClientProtocol clientType, string clientUriPrefix, string clientTypeString)
{
var serviceClient = new WebPubSubServiceSubClass(new Uri("https://localhost"), "hub", new DefaultAzureCredential());
Expand Down
Loading