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

feat/event-listeners #220

Merged
merged 20 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c6e7a69
add entity classes
mohitpubnub May 6, 2024
4295001
Merge branch 'master' into CLEN-1851
mohitpubnub May 19, 2024
7cdc839
added entity implementation
mohitpubnub Jun 4, 2024
21b345e
Merge branch 'master' into CLEN-1851
mohitpubnub Jun 4, 2024
6afcfdc
support for `User` and `Channel`-`Metadata` entities
mohitpubnub Jun 4, 2024
edc8023
UWP: added entity class references
mohitpubnub Jun 4, 2024
5f8be23
typo in method name
mohitpubnub Jun 4, 2024
3596777
acceptance tests using new enttities and event listeners
mohitpubnub Jun 5, 2024
4c5ae5d
remove magic strings
mohitpubnub Jun 6, 2024
045ba56
set `EnableEventEngine` and fix relevant issues
mohitpubnub Jun 10, 2024
47c136b
fix vulnerability alert: example code #199
mohitpubnub Jun 12, 2024
d56cfc4
fix: handling connection failure status with additional information t…
mohitpubnub Jun 13, 2024
fcb7848
`EventListener` class for registering event handlers for each type of…
mohitpubnub Jun 19, 2024
6cbb75f
refactor: Remove `TelemetryManager` from sdk (#224)
mohitpubnub Oct 29, 2024
19c0359
Merge branch 'master' into CLEN-1851
mohitpubnub Oct 29, 2024
f99f5a4
fix: unsubscribe issue due to duplicate channles/groups
mohitpubnub Oct 30, 2024
0055eda
fix: `HereNow` issue with async- showing error: true even with status…
mohitpubnub Oct 30, 2024
5bef325
added logging to httpClient Service, optional parameter support in Pu…
mohitpubnub Oct 30, 2024
d6a5bbc
Add some more missinng ConfigureAwait(false)
jakub-grzesiowski Oct 30, 2024
7108453
PubNub SDK v7.0.0.0 release.
pubnub-release-bot Oct 30, 2024
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
18 changes: 10 additions & 8 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,22 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.x
5.0.x
6.0.x
7.0.x
- name: Build packages
env:
WORKSPACE_PATH: ${{ github.workspace }}
run: .\\.github\\workflows\\release\\build-packages.ps1
# - name: Run unit tests
# env:
# PN_PUB_KEY: ${{ secrets.PN_PUB_KEY }}
# PN_SUB_KEY: ${{ secrets.PN_SUB_KEY }}
# PN_SEC_KEY: ${{ secrets.PN_SEC_KEY }}
# run: dotnet test .\\src\\UnitTests\\PubnubApiPCL.Tests\\PubnubApiPCL.Tests.csproj --verbosity normal --logger trx
- name: Run unit tests
env:
PN_PUB_KEY: ${{ secrets.SDK_PUB_KEY }}
PN_SUB_KEY: ${{ secrets.SDK_SUB_KEY }}
PN_SEC_KEY: ${{ secrets.SDK_SEC_KEY }}
PN_PAM_PUB_KEY: ${{ secrets.SDK_PAM_PUB_KEY }}
PN_PAM_SUB_KEY: ${{ secrets.SDK_PAM_SUB_KEY }}
PN_PAM_SEC_KEY: ${{ secrets.SDK_PAM_SEC_KEY }}
run: dotnet test .\\src\\UnitTests\\PubnubApiPCL.Tests\\PubnubApiPCL.Tests.csproj --verbosity normal --logger "console;verbosity=detailed"
- name: Cancel workflow runs for commit on error
if: failure()
uses: ./.github/.release/actions/actions/utils/fast-jobs-failure
Expand Down Expand Up @@ -91,7 +93,7 @@ jobs:
run: |
Copy-Item -Path "${{ github.workspace }}/sdk-specifications/features/access/*" -Destination "${{ github.workspace }}/src/UnitTests/AcceptanceTests/Features" -Recurse
cd ./UnitTests/AcceptanceTests
dotnet test --no-build --verbosity normal --logger trx --results-directory ./results
dotnet test --no-build --verbosity normal --logger "console;verbosity=detailed" --results-directory ./results
- name: Upload acceptance tests reports
if: always()
uses: actions/upload-artifact@v4
Expand Down
29 changes: 21 additions & 8 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
name: c-sharp
version: "6.20.2"
version: "7.0.0"
schema: 1
scm: github.com/pubnub/c-sharp
changelog:
- date: 2024-10-30
version: v7.0.0
changes:
- type: feature
text: "Added support for `Channel`, `ChannelGroup`, `Subscription` and `SubscriptionSet`, `ChannelMetadata`, `UserMetadata` entities for Subscribe related operation."
- type: feature
text: "BREAKING CHANGES: Added new event listeners support."
- type: feature
text: "BREAKING CHANGES: All apis calls will be made through `HttpClient` by default."
- type: feature
text: "Default value for `EnableEventEngine` is set to `true`, Subscribe operation will be executed by event engine by default."
- type: improvement
text: "Removed telemetry manager."
- date: 2024-10-03
version: v6.20.2
changes:
Expand Down Expand Up @@ -793,7 +806,7 @@ features:
- QUERY-PARAM
supported-platforms:
-
version: Pubnub 'C#' 6.20.2
version: Pubnub 'C#' 7.0.0
platforms:
- Windows 10 and up
- Windows Server 2008 and up
Expand All @@ -804,7 +817,7 @@ supported-platforms:
- .Net Framework 4.6.1+
- .Net Framework 6.0
-
version: PubnubPCL 'C#' 6.20.2
version: PubnubPCL 'C#' 7.0.0
platforms:
- Xamarin.Android
- Xamarin.iOS
Expand All @@ -824,7 +837,7 @@ supported-platforms:
- .Net Core
- .Net 6.0
-
version: PubnubUWP 'C#' 6.20.2
version: PubnubUWP 'C#' 7.0.0
platforms:
- Windows Phone 10
- Universal Windows Apps
Expand All @@ -848,7 +861,7 @@ sdks:
distribution-type: source
distribution-repository: GitHub
package-name: Pubnub
location: https://github.com/pubnub/c-sharp/releases/tag/v6.20.2.0
location: https://github.com/pubnub/c-sharp/releases/tag/v7.0.0.0
requires:
-
name: ".Net"
Expand Down Expand Up @@ -1131,7 +1144,7 @@ sdks:
distribution-type: source
distribution-repository: GitHub
package-name: PubNubPCL
location: https://github.com/pubnub/c-sharp/releases/tag/v6.20.2.0
location: https://github.com/pubnub/c-sharp/releases/tag/v7.0.0.0
requires:
-
name: ".Net Core"
Expand Down Expand Up @@ -1490,7 +1503,7 @@ sdks:
distribution-type: source
distribution-repository: GitHub
package-name: PubnubUWP
location: https://github.com/pubnub/c-sharp/releases/tag/v6.20.2.0
location: https://github.com/pubnub/c-sharp/releases/tag/v7.0.0.0
requires:
-
name: "Universal Windows Platform Development"
Expand Down Expand Up @@ -1649,4 +1662,4 @@ sdks:
- Windows Server 2012 R2 Foundation
- Windows Server 2012 R2 Essentials
- Windows Server 2012 R2 Standard
- Windows Server 2012 R2 Datacenter
- Windows Server 2012 R2 Datacenter
9 changes: 9 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
v7.0.0 - October 30 2024
-----------------------------
- Added: added support for `Channel`, `ChannelGroup`, `Subscription` and `SubscriptionSet`, `ChannelMetadata`, `UserMetadata` entities for Subscribe related operation.
- BREAKING CHANGES: Added new event listeners support.
- BREAKING CHANGES: All apis calls will be made through `HttpClient` by default.
- Added: default value for `EnableEventEngine` is set to `true`, Subscribe operation will be executed by event engine by default.

- Modified: removed telemetry manager.

v6.20.2 - October 03 2024
-----------------------------
- Fixed: fixes issue of listener not being removed on RemoveListener call.
Expand Down
13 changes: 5 additions & 8 deletions src/Api/PubnubApi/Builder/ResponseBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;

namespace PubnubApi
{
Expand All @@ -13,9 +10,9 @@ internal class ResponseBuilder

public ResponseBuilder(PNConfiguration pubnubConfig, IJsonPluggableLibrary jsonPluggableLibrary, IPubnubLog log)
{
this.config = pubnubConfig;
this.jsonLib = jsonPluggableLibrary;
this.pubnubLog = log;
config = pubnubConfig;
jsonLib = jsonPluggableLibrary;
pubnubLog = log;
}

public T JsonToObject<T>(List<object> result, bool internalObject)
Expand All @@ -28,7 +25,7 @@ public T JsonToObject<T>(List<object> result, bool internalObject)
}
else
{
NewtonsoftJsonDotNet jsonNewtonLib = new NewtonsoftJsonDotNet(this.config, this.pubnubLog);
NewtonsoftJsonDotNet jsonNewtonLib = new NewtonsoftJsonDotNet(config, pubnubLog);
ret = jsonNewtonLib.DeserializeToObject<T>(result);
}

Expand Down
10 changes: 4 additions & 6 deletions src/Api/PubnubApi/Builder/StatusBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;

namespace PubnubApi
{
public class StatusBuilder
public class StatusBuilder
{
private readonly PNConfiguration config;
private readonly IJsonPluggableLibrary jsonLibrary;
Expand Down Expand Up @@ -98,11 +96,11 @@ public PNStatus CreateStatusResponse<T>(PNOperationType type, PNStatusCategory c

if (asyncRequestState != null)
{
if (asyncRequestState.Request != null)
if (asyncRequestState.RequestCancellationTokenSource != null)
{
status.ClientRequest = asyncRequestState.Request;
status.ClientRequest = asyncRequestState.RequestCancellationTokenSource;

HttpValueCollection restUriQueryCollection = HttpUtility.ParseQueryString(asyncRequestState.Request.RequestUri.Query);
HttpValueCollection restUriQueryCollection = HttpUtility.ParseQueryString(new Uri(asyncRequestState.Response.RequestUrl).Query);
if (restUriQueryCollection.ContainsKey("auth"))
{
string auth = restUriQueryCollection["auth"];
Expand Down
45 changes: 34 additions & 11 deletions src/Api/PubnubApi/Builder/UriUtil.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using PubnubApi.EndPoint;

namespace PubnubApi
{
public class UriUtil
public static class UriUtil
{
public static string EncodeUriComponent(string s, PNOperationType type, bool ignoreComma, bool ignoreColon, bool ignorePercent2fEncode)
{
Expand Down Expand Up @@ -75,13 +78,7 @@ public static string EncodeUriComponent(string s, PNOperationType type, bool ign
}
else
{
string escapeChar = System.Uri.EscapeDataString(ch.ToString());
#if NET35 || NET40
if (escapeChar == ch.ToString() && IsUnsafeToEncode(ch, ignoreComma, ignoreColon))
{
escapeChar = string.Format(CultureInfo.InvariantCulture, "%{0}{1}", ToHex(ch / 16), ToHex(ch % 16));
}
#endif
string escapeChar = Uri.EscapeDataString(ch.ToString());
o.Append(escapeChar);
}
}
Expand Down Expand Up @@ -160,7 +157,7 @@ private static int ConvertToUtf32(string s, int index)
}

// Check if the character at index is a high surrogate.
int temp1 = (int)s[index] - HighSurrogateStart;
int temp1 = s[index] - HighSurrogateStart;
if (temp1 >= 0 && temp1 <= 0x7ff)
{
// Found a surrogate char.
Expand All @@ -169,7 +166,7 @@ private static int ConvertToUtf32(string s, int index)
// Found a high surrogate.
if (index < s.Length - 1)
{
int temp2 = (int)s[index + 1] - LowSurrogateStart;
int temp2 = s[index + 1] - LowSurrogateStart;
if (temp2 >= 0 && temp2 <= 0x3ff)
{
// Found a low surrogate.
Expand All @@ -194,7 +191,33 @@ private static int ConvertToUtf32(string s, int index)
}

// Not a high-surrogate or low-surrogate. Genereate the UTF32 value for the BMP characters.
return (int)s[index];
return s[index];
}

public static string BuildQueryString(Dictionary<string, string> queryStringParamMap)
{
return string.Join("&", queryStringParamMap?.OrderBy(kvp => kvp.Key, StringComparer.Ordinal).Select(kvp => string.Format(CultureInfo.InvariantCulture, "{0}={1}", kvp.Key, kvp.Value)).ToArray() ?? Array.Empty<string>());
}

public static string GetFileUrl(string fileId, string fileName, string channel, PNConfiguration pnConfiguration, Pubnub pubnub, TokenManager tokenmanager)
{
var requestParameters = new RequestParameter()
{
RequestType = Constants.GET,
PathSegment = [
"v1",
"files",
pnConfiguration.SubscribeKey,
"channels",
channel,
"files",
fileId,
fileName
],
Query = new Dictionary<string, string>()
};
var transportRequest = pubnub.transportMiddleware.PreapareTransportRequest(requestParameter:requestParameters, PNOperationType.PNFileUrlOperation);
return transportRequest.RequestUrl;
}
}
}
35 changes: 35 additions & 0 deletions src/Api/PubnubApi/Builder/UrlParameterConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;

namespace PubnubApi.EndPoint
{

internal static class UrlParameterConverter
{
public static string MapEnumValueToEndpoint(string enumValue)
{
string endpointParameterName = String.Empty;
if (enumValue.ToLowerInvariant() == "custom")
{
endpointParameterName = "custom";
}
else if (enumValue.ToLowerInvariant() == "uuid")
{
endpointParameterName = "uuid";
}
else if (enumValue.ToLowerInvariant() == "channel")
{
endpointParameterName = "channel";
}
else if (enumValue.ToLowerInvariant() == "channel_custom")
{
endpointParameterName = "channel.custom";
}
else if (enumValue.ToLowerInvariant() == "uuid_custom")
{
endpointParameterName = "uuid.custom";
}

return endpointParameterName;
}
}
}
Loading
Loading