From 93956fa80ec74cfbca5822d946ccc85c048689b7 Mon Sep 17 00:00:00 2001 From: Jialin Xin Date: Mon, 1 Jul 2024 22:14:10 +0800 Subject: [PATCH 1/3] Fix SetState not work --- .../src/Models/Trigger/ConnectEventResponse.cs | 1 + .../src/Models/Trigger/UserEventResponse.cs | 3 ++- .../src/Shared/ConnectionStatesConverter.cs | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sdk/webpubsub/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub/src/Models/Trigger/ConnectEventResponse.cs b/sdk/webpubsub/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub/src/Models/Trigger/ConnectEventResponse.cs index 2dd1c8f07bda6..3f380375bfbee 100644 --- a/sdk/webpubsub/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub/src/Models/Trigger/ConnectEventResponse.cs +++ b/sdk/webpubsub/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub/src/Models/Trigger/ConnectEventResponse.cs @@ -35,6 +35,7 @@ internal override WebPubSubStatusCode StatusCode /// The connection states. /// [JsonPropertyName("states")] + [JsonConverter(typeof(ConnectionStatesConverter))] public IReadOnlyDictionary ConnectionStates => _states; /// diff --git a/sdk/webpubsub/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub/src/Models/Trigger/UserEventResponse.cs b/sdk/webpubsub/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub/src/Models/Trigger/UserEventResponse.cs index 801a0377dcd78..514a2d04f0b98 100644 --- a/sdk/webpubsub/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub/src/Models/Trigger/UserEventResponse.cs +++ b/sdk/webpubsub/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub/src/Models/Trigger/UserEventResponse.cs @@ -36,7 +36,8 @@ internal override WebPubSubStatusCode StatusCode /// The connection states. /// [JsonPropertyName("states")] - public IReadOnlyDictionary ConnectionStates { get; set; } + [JsonConverter(typeof(ConnectionStatesConverter))] + public IReadOnlyDictionary ConnectionStates => _states; /// /// Message. diff --git a/sdk/webpubsub/Microsoft.Azure.WebPubSub.Common/src/Shared/ConnectionStatesConverter.cs b/sdk/webpubsub/Microsoft.Azure.WebPubSub.Common/src/Shared/ConnectionStatesConverter.cs index 57b8d1cb2eaeb..05d20bbc527db 100644 --- a/sdk/webpubsub/Microsoft.Azure.WebPubSub.Common/src/Shared/ConnectionStatesConverter.cs +++ b/sdk/webpubsub/Microsoft.Azure.WebPubSub.Common/src/Shared/ConnectionStatesConverter.cs @@ -8,7 +8,7 @@ // This is shared between WPS.Common and WPS.AspNetCore -namespace Microsoft.Azure.WebPubSub.Common +namespace Microsoft.Azure.Functions.Worker { /// /// Converter to turn the ConnectionStates dictionary into a regular JSON From 32ad3a6de18ee7de540ea281eae94fc4a5d3f451 Mon Sep 17 00:00:00 2001 From: JialinXin Date: Tue, 2 Jul 2024 11:04:05 +0800 Subject: [PATCH 2/3] Fix namespace. --- .../src/Models/Trigger/ConnectEventResponse.cs | 1 + .../src/Models/Trigger/UserEventResponse.cs | 1 + .../src/Shared/ConnectionStatesConverter.cs | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sdk/webpubsub/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub/src/Models/Trigger/ConnectEventResponse.cs b/sdk/webpubsub/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub/src/Models/Trigger/ConnectEventResponse.cs index 3f380375bfbee..cfe700cd4005d 100644 --- a/sdk/webpubsub/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub/src/Models/Trigger/ConnectEventResponse.cs +++ b/sdk/webpubsub/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub/src/Models/Trigger/ConnectEventResponse.cs @@ -6,6 +6,7 @@ using System.ComponentModel; using System.Linq; using System.Text.Json.Serialization; +using Microsoft.Azure.WebPubSub.Common; namespace Microsoft.Azure.Functions.Worker { diff --git a/sdk/webpubsub/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub/src/Models/Trigger/UserEventResponse.cs b/sdk/webpubsub/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub/src/Models/Trigger/UserEventResponse.cs index 514a2d04f0b98..92c57e61f4821 100644 --- a/sdk/webpubsub/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub/src/Models/Trigger/UserEventResponse.cs +++ b/sdk/webpubsub/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub/src/Models/Trigger/UserEventResponse.cs @@ -6,6 +6,7 @@ using System.ComponentModel; using System.Runtime.Serialization; using System.Text.Json.Serialization; +using Microsoft.Azure.WebPubSub.Common; namespace Microsoft.Azure.Functions.Worker { diff --git a/sdk/webpubsub/Microsoft.Azure.WebPubSub.Common/src/Shared/ConnectionStatesConverter.cs b/sdk/webpubsub/Microsoft.Azure.WebPubSub.Common/src/Shared/ConnectionStatesConverter.cs index 05d20bbc527db..57b8d1cb2eaeb 100644 --- a/sdk/webpubsub/Microsoft.Azure.WebPubSub.Common/src/Shared/ConnectionStatesConverter.cs +++ b/sdk/webpubsub/Microsoft.Azure.WebPubSub.Common/src/Shared/ConnectionStatesConverter.cs @@ -8,7 +8,7 @@ // This is shared between WPS.Common and WPS.AspNetCore -namespace Microsoft.Azure.Functions.Worker +namespace Microsoft.Azure.WebPubSub.Common { /// /// Converter to turn the ConnectionStates dictionary into a regular JSON From 2774707486cd7727ef219c996444ec1ac3755e63 Mon Sep 17 00:00:00 2001 From: JialinXin Date: Tue, 2 Jul 2024 13:13:40 +0800 Subject: [PATCH 3/3] Add API updates. --- ...zure.Functions.Worker.Extensions.WebPubSub.netstandard2.0.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/webpubsub/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub/api/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub.netstandard2.0.cs b/sdk/webpubsub/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub/api/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub.netstandard2.0.cs index ee553b8d299cd..0fb76e2439423 100644 --- a/sdk/webpubsub/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub/api/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub.netstandard2.0.cs +++ b/sdk/webpubsub/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub/api/Microsoft.Azure.Functions.Worker.Extensions.WebPubSub.netstandard2.0.cs @@ -169,7 +169,7 @@ public UserEventResponse() { } public UserEventResponse(System.BinaryData data, Microsoft.Azure.Functions.Worker.WebPubSubDataType dataType) { } public UserEventResponse(string data, Microsoft.Azure.Functions.Worker.WebPubSubDataType dataType = Microsoft.Azure.Functions.Worker.WebPubSubDataType.Text) { } [System.Text.Json.Serialization.JsonPropertyNameAttribute("states")] - public System.Collections.Generic.IReadOnlyDictionary ConnectionStates { get { throw null; } set { } } + public System.Collections.Generic.IReadOnlyDictionary ConnectionStates { get { throw null; } } [System.Text.Json.Serialization.JsonPropertyNameAttribute("data")] public System.BinaryData Data { get { throw null; } set { } } [System.Text.Json.Serialization.JsonPropertyNameAttribute("dataType")]