Skip to content

Commit

Permalink
add socketio support when generating client access uri (#46942)
Browse files Browse the repository at this point in the history
* add socketio support when generating client access uri

* add changelog

* update api

---------

Co-authored-by: tomnguyen <chuongnguyen@microsoft.com>
  • Loading branch information
cqnguy23 and cqnguy23 authored Nov 4, 2024
1 parent 52190ed commit 1bb0be0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 0 deletions.
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 @@ -9,6 +9,7 @@ public enum WebPubSubClientProtocol
{
Default = 0,
Mqtt = 1,
SocketIO = 2,
}
public enum WebPubSubPermission
{
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

0 comments on commit 1bb0be0

Please sign in to comment.