Skip to content

Commit 7f4180c

Browse files
mohitpubnubjakub-grzesiowskipubnub-release-bot
authored
feat/event-listeners (#220)
* add entity classes * added entity implementation * support for `User` and `Channel`-`Metadata` entities * UWP: added entity class references * typo in method name * acceptance tests using new enttities and event listeners * remove magic strings * set `EnableEventEngine` and fix relevant issues * fix vulnerability alert: example code #199 * fix: handling connection failure status with additional information to user * `EventListener` class for registering event handlers for each type of event * refactor: Remove `TelemetryManager` from sdk (#224) * Remove TelemetryManager from the sdk * Transport layer (#225) * * Target framework upgrade * Initial code for HttpClient * Integration of TransportLayer with all endpoints except File and Subscribe operations * send and download file apis refactoring * code cleanup: removed unnecessary usings for threading.channels * removed support for older netstandartds * Fix build issues for Unity and UWP projects * retire old httpWebRequest * CI Tests Fix (#228) * temporarily remove one assert from TestSubscribeDecryptionOnNonEncryptedMessage * re-enable unit tests on branch * disable stub test * remove channels argument exception from UrlRequestBuilder * temporarily disable tests that were causing the CI to hang * update key-set used by tests * Fix broken Encryption tests * Disable global HereNow tests (for now) * re-enable access manager dependant tests * Revert "re-enable access manager dependant tests" This reverts commit dff644b. * Test increased timeouts in ThenManageMembershipShouldReturnEventInfo * Revert "Test increased timeouts in ThenManageMembershipShouldReturnEventInfo" This reverts commit fc129da. * Fix potentially faulty async calls in EncryptionTests * Increase verbosity for CI debugging * test increasing --logger verbosity * add a NUnit ConsoleTraceListener * add a simple debug writeline to test logging * Update .pubnub.yml for .Net version support (#223) * fix encryption tests PAM issue * Fix more of file tests * add missing test teardowns, replace v2 PAM access grants with v3 ones in tests that got a PAM 403 * change to PAM v3 in WhenObjectChannelMetadata * failing test debug assert * add temp debug method for PubnubCommon values * Change PAM v2 to v3 in more tests, more failing test debug * update .yml test keys ids * add debug to failing ci test * debug on file tests * tests yml sdk keys change * remove old test debugs * Remove deprecated build targets * Fix missing UWP includes --------- Co-authored-by: Mohit Tejani <[email protected]> * fix acceptance tests errors * * fixes issue reported by acceptance tests in AppContextApi. * Added support for Patch requests in client library * * added missing includes for UWP (missed in last merge!) * fix current userId memenership issue for AppContext Api * * fix: removed references of old http client code, added request timeout mechanism, fixes to adhere to existing response generation mechanism by applying request state values as per response * fix: removeMembership for current user scenario execution * refactor: moved out enumToUrlParamName conversation utility to build utility directory, moved unnecessary log messages from internet utility method * fixes issues found in channelGroup, audit, publish, signal operation through unit/integration tests * files: fix issue of uploading and downloading files due to wrong header information sent through default http client component * Unit and Integration Tests: increased delay value for Grant response wait. * * Code cleanup: removed commented code in client library, better error handling in default http client library, removed code for UrlProcess request from PubNubCore class, fixed issues with generate file url * build: update default runner group value with organization * Add/re-add ConfigureAwait(false) in await calls to prevent Unity-side deadlocks * Add few more missing ConfigureAwait(false) * Added Support for Porxy. Code Cleanup for Pubnub, PubnubCoreBase, PNConfiguration class, Code Cleanup - removed dead codes in various files and removed old PubnubHttpClient footprints. * fix: Serialization failure for User publish/signal message at NewtonsoftJsonNet library * BREAKING CHANGE: Default Reconnection Policy set to `EXPONENTIAL`. * File upload failure edge cases handling with proper exception messages. * Refactored Check Internet status execution a bit (many more to come) to fix Unity engine impact. * Old subscription logic cleanup: removing many state/internetstatus information store * Unsubscribe operation refactoring: removed unncessary processings * set default event engine enabled * removed timer.cs, tuple.cs which was there for older .net versions * fix: presence tests (passing locally) * reverted eventengine enabled flag reset for Presence Tests * update test to have different channel names for presence tests * presence test fix for 403 permission * attempt to fix unit/integartion test for subscribe * fix: Patch work for internet status chekcing execution to make it compatible with single threaded environment. Disable ee for unit/integration tests --------- Co-authored-by: PUBNUB\jakub.grzesiowski <[email protected]> Co-authored-by: jakub-grzesiowski <[email protected]> --------- Co-authored-by: PUBNUB\jakub.grzesiowski <[email protected]> Co-authored-by: jakub-grzesiowski <[email protected]> * fix: unsubscribe issue due to duplicate channles/groups * fix: `HereNow` issue with async- showing error: true even with status 200 * added logging to httpClient Service, optional parameter support in Pubnub constructor for middleware and client library * Add some more missinng ConfigureAwait(false) * PubNub SDK v7.0.0.0 release. --------- Co-authored-by: PUBNUB\jakub.grzesiowski <[email protected]> Co-authored-by: jakub-grzesiowski <[email protected]> Co-authored-by: PubNub Release Bot <[email protected]>
1 parent aedbf5c commit 7f4180c

File tree

161 files changed

+16337
-21255
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+16337
-21255
lines changed

.github/workflows/run-tests.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,22 @@ jobs:
3131
uses: actions/setup-dotnet@v4
3232
with:
3333
dotnet-version: |
34-
3.x
3534
5.0.x
3635
6.0.x
3736
7.0.x
3837
- name: Build packages
3938
env:
4039
WORKSPACE_PATH: ${{ github.workspace }}
4140
run: .\\.github\\workflows\\release\\build-packages.ps1
42-
# - name: Run unit tests
43-
# env:
44-
# PN_PUB_KEY: ${{ secrets.PN_PUB_KEY }}
45-
# PN_SUB_KEY: ${{ secrets.PN_SUB_KEY }}
46-
# PN_SEC_KEY: ${{ secrets.PN_SEC_KEY }}
47-
# run: dotnet test .\\src\\UnitTests\\PubnubApiPCL.Tests\\PubnubApiPCL.Tests.csproj --verbosity normal --logger trx
41+
- name: Run unit tests
42+
env:
43+
PN_PUB_KEY: ${{ secrets.SDK_PUB_KEY }}
44+
PN_SUB_KEY: ${{ secrets.SDK_SUB_KEY }}
45+
PN_SEC_KEY: ${{ secrets.SDK_SEC_KEY }}
46+
PN_PAM_PUB_KEY: ${{ secrets.SDK_PAM_PUB_KEY }}
47+
PN_PAM_SUB_KEY: ${{ secrets.SDK_PAM_SUB_KEY }}
48+
PN_PAM_SEC_KEY: ${{ secrets.SDK_PAM_SEC_KEY }}
49+
run: dotnet test .\\src\\UnitTests\\PubnubApiPCL.Tests\\PubnubApiPCL.Tests.csproj --verbosity normal --logger "console;verbosity=detailed"
4850
- name: Cancel workflow runs for commit on error
4951
if: failure()
5052
uses: ./.github/.release/actions/actions/utils/fast-jobs-failure
@@ -91,7 +93,7 @@ jobs:
9193
run: |
9294
Copy-Item -Path "${{ github.workspace }}/sdk-specifications/features/access/*" -Destination "${{ github.workspace }}/src/UnitTests/AcceptanceTests/Features" -Recurse
9395
cd ./UnitTests/AcceptanceTests
94-
dotnet test --no-build --verbosity normal --logger trx --results-directory ./results
96+
dotnet test --no-build --verbosity normal --logger "console;verbosity=detailed" --results-directory ./results
9597
- name: Upload acceptance tests reports
9698
if: always()
9799
uses: actions/upload-artifact@v4

.pubnub.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
name: c-sharp
2-
version: "6.20.2"
2+
version: "7.0.0"
33
schema: 1
44
scm: github.com/pubnub/c-sharp
55
changelog:
6+
- date: 2024-10-30
7+
version: v7.0.0
8+
changes:
9+
- type: feature
10+
text: "Added support for `Channel`, `ChannelGroup`, `Subscription` and `SubscriptionSet`, `ChannelMetadata`, `UserMetadata` entities for Subscribe related operation."
11+
- type: feature
12+
text: "BREAKING CHANGES: Added new event listeners support."
13+
- type: feature
14+
text: "BREAKING CHANGES: All apis calls will be made through `HttpClient` by default."
15+
- type: feature
16+
text: "Default value for `EnableEventEngine` is set to `true`, Subscribe operation will be executed by event engine by default."
17+
- type: improvement
18+
text: "Removed telemetry manager."
619
- date: 2024-10-03
720
version: v6.20.2
821
changes:
@@ -793,7 +806,7 @@ features:
793806
- QUERY-PARAM
794807
supported-platforms:
795808
-
796-
version: Pubnub 'C#' 6.20.2
809+
version: Pubnub 'C#' 7.0.0
797810
platforms:
798811
- Windows 10 and up
799812
- Windows Server 2008 and up
@@ -804,7 +817,7 @@ supported-platforms:
804817
- .Net Framework 4.6.1+
805818
- .Net Framework 6.0
806819
-
807-
version: PubnubPCL 'C#' 6.20.2
820+
version: PubnubPCL 'C#' 7.0.0
808821
platforms:
809822
- Xamarin.Android
810823
- Xamarin.iOS
@@ -824,7 +837,7 @@ supported-platforms:
824837
- .Net Core
825838
- .Net 6.0
826839
-
827-
version: PubnubUWP 'C#' 6.20.2
840+
version: PubnubUWP 'C#' 7.0.0
828841
platforms:
829842
- Windows Phone 10
830843
- Universal Windows Apps
@@ -848,7 +861,7 @@ sdks:
848861
distribution-type: source
849862
distribution-repository: GitHub
850863
package-name: Pubnub
851-
location: https://github.com/pubnub/c-sharp/releases/tag/v6.20.2.0
864+
location: https://github.com/pubnub/c-sharp/releases/tag/v7.0.0.0
852865
requires:
853866
-
854867
name: ".Net"
@@ -1131,7 +1144,7 @@ sdks:
11311144
distribution-type: source
11321145
distribution-repository: GitHub
11331146
package-name: PubNubPCL
1134-
location: https://github.com/pubnub/c-sharp/releases/tag/v6.20.2.0
1147+
location: https://github.com/pubnub/c-sharp/releases/tag/v7.0.0.0
11351148
requires:
11361149
-
11371150
name: ".Net Core"
@@ -1490,7 +1503,7 @@ sdks:
14901503
distribution-type: source
14911504
distribution-repository: GitHub
14921505
package-name: PubnubUWP
1493-
location: https://github.com/pubnub/c-sharp/releases/tag/v6.20.2.0
1506+
location: https://github.com/pubnub/c-sharp/releases/tag/v7.0.0.0
14941507
requires:
14951508
-
14961509
name: "Universal Windows Platform Development"
@@ -1649,4 +1662,4 @@ sdks:
16491662
- Windows Server 2012 R2 Foundation
16501663
- Windows Server 2012 R2 Essentials
16511664
- Windows Server 2012 R2 Standard
1652-
- Windows Server 2012 R2 Datacenter
1665+
- Windows Server 2012 R2 Datacenter

CHANGELOG

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
v7.0.0 - October 30 2024
2+
-----------------------------
3+
- Added: added support for `Channel`, `ChannelGroup`, `Subscription` and `SubscriptionSet`, `ChannelMetadata`, `UserMetadata` entities for Subscribe related operation.
4+
- BREAKING CHANGES: Added new event listeners support.
5+
- BREAKING CHANGES: All apis calls will be made through `HttpClient` by default.
6+
- Added: default value for `EnableEventEngine` is set to `true`, Subscribe operation will be executed by event engine by default.
7+
8+
- Modified: removed telemetry manager.
9+
110
v6.20.2 - October 03 2024
211
-----------------------------
312
- Fixed: fixes issue of listener not being removed on RemoveListener call.

src/Api/PubnubApi/Builder/ResponseBuilder.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
1+
using System.Collections.Generic;
52

63
namespace PubnubApi
74
{
@@ -13,9 +10,9 @@ internal class ResponseBuilder
1310

1411
public ResponseBuilder(PNConfiguration pubnubConfig, IJsonPluggableLibrary jsonPluggableLibrary, IPubnubLog log)
1512
{
16-
this.config = pubnubConfig;
17-
this.jsonLib = jsonPluggableLibrary;
18-
this.pubnubLog = log;
13+
config = pubnubConfig;
14+
jsonLib = jsonPluggableLibrary;
15+
pubnubLog = log;
1916
}
2017

2118
public T JsonToObject<T>(List<object> result, bool internalObject)
@@ -28,7 +25,7 @@ public T JsonToObject<T>(List<object> result, bool internalObject)
2825
}
2926
else
3027
{
31-
NewtonsoftJsonDotNet jsonNewtonLib = new NewtonsoftJsonDotNet(this.config, this.pubnubLog);
28+
NewtonsoftJsonDotNet jsonNewtonLib = new NewtonsoftJsonDotNet(config, pubnubLog);
3229
ret = jsonNewtonLib.DeserializeToObject<T>(result);
3330
}
3431

src/Api/PubnubApi/Builder/StatusBuilder.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4-
using System.Net;
5-
using System.Text;
64

75
namespace PubnubApi
86
{
9-
public class StatusBuilder
7+
public class StatusBuilder
108
{
119
private readonly PNConfiguration config;
1210
private readonly IJsonPluggableLibrary jsonLibrary;
@@ -98,11 +96,11 @@ public PNStatus CreateStatusResponse<T>(PNOperationType type, PNStatusCategory c
9896

9997
if (asyncRequestState != null)
10098
{
101-
if (asyncRequestState.Request != null)
99+
if (asyncRequestState.RequestCancellationTokenSource != null)
102100
{
103-
status.ClientRequest = asyncRequestState.Request;
101+
status.ClientRequest = asyncRequestState.RequestCancellationTokenSource;
104102

105-
HttpValueCollection restUriQueryCollection = HttpUtility.ParseQueryString(asyncRequestState.Request.RequestUri.Query);
103+
HttpValueCollection restUriQueryCollection = HttpUtility.ParseQueryString(new Uri(asyncRequestState.Response.RequestUrl).Query);
106104
if (restUriQueryCollection.ContainsKey("auth"))
107105
{
108106
string auth = restUriQueryCollection["auth"];

src/Api/PubnubApi/Builder/UriUtil.cs

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Globalization;
4+
using System.Linq;
35
using System.Text;
6+
using PubnubApi.EndPoint;
47

58
namespace PubnubApi
69
{
7-
public class UriUtil
10+
public static class UriUtil
811
{
912
public static string EncodeUriComponent(string s, PNOperationType type, bool ignoreComma, bool ignoreColon, bool ignorePercent2fEncode)
1013
{
@@ -75,13 +78,7 @@ public static string EncodeUriComponent(string s, PNOperationType type, bool ign
7578
}
7679
else
7780
{
78-
string escapeChar = System.Uri.EscapeDataString(ch.ToString());
79-
#if NET35 || NET40
80-
if (escapeChar == ch.ToString() && IsUnsafeToEncode(ch, ignoreComma, ignoreColon))
81-
{
82-
escapeChar = string.Format(CultureInfo.InvariantCulture, "%{0}{1}", ToHex(ch / 16), ToHex(ch % 16));
83-
}
84-
#endif
81+
string escapeChar = Uri.EscapeDataString(ch.ToString());
8582
o.Append(escapeChar);
8683
}
8784
}
@@ -160,7 +157,7 @@ private static int ConvertToUtf32(string s, int index)
160157
}
161158

162159
// Check if the character at index is a high surrogate.
163-
int temp1 = (int)s[index] - HighSurrogateStart;
160+
int temp1 = s[index] - HighSurrogateStart;
164161
if (temp1 >= 0 && temp1 <= 0x7ff)
165162
{
166163
// Found a surrogate char.
@@ -169,7 +166,7 @@ private static int ConvertToUtf32(string s, int index)
169166
// Found a high surrogate.
170167
if (index < s.Length - 1)
171168
{
172-
int temp2 = (int)s[index + 1] - LowSurrogateStart;
169+
int temp2 = s[index + 1] - LowSurrogateStart;
173170
if (temp2 >= 0 && temp2 <= 0x3ff)
174171
{
175172
// Found a low surrogate.
@@ -194,7 +191,33 @@ private static int ConvertToUtf32(string s, int index)
194191
}
195192

196193
// Not a high-surrogate or low-surrogate. Genereate the UTF32 value for the BMP characters.
197-
return (int)s[index];
194+
return s[index];
195+
}
196+
197+
public static string BuildQueryString(Dictionary<string, string> queryStringParamMap)
198+
{
199+
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>());
200+
}
201+
202+
public static string GetFileUrl(string fileId, string fileName, string channel, PNConfiguration pnConfiguration, Pubnub pubnub, TokenManager tokenmanager)
203+
{
204+
var requestParameters = new RequestParameter()
205+
{
206+
RequestType = Constants.GET,
207+
PathSegment = [
208+
"v1",
209+
"files",
210+
pnConfiguration.SubscribeKey,
211+
"channels",
212+
channel,
213+
"files",
214+
fileId,
215+
fileName
216+
],
217+
Query = new Dictionary<string, string>()
218+
};
219+
var transportRequest = pubnub.transportMiddleware.PreapareTransportRequest(requestParameter:requestParameters, PNOperationType.PNFileUrlOperation);
220+
return transportRequest.RequestUrl;
198221
}
199222
}
200223
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
3+
namespace PubnubApi.EndPoint
4+
{
5+
6+
internal static class UrlParameterConverter
7+
{
8+
public static string MapEnumValueToEndpoint(string enumValue)
9+
{
10+
string endpointParameterName = String.Empty;
11+
if (enumValue.ToLowerInvariant() == "custom")
12+
{
13+
endpointParameterName = "custom";
14+
}
15+
else if (enumValue.ToLowerInvariant() == "uuid")
16+
{
17+
endpointParameterName = "uuid";
18+
}
19+
else if (enumValue.ToLowerInvariant() == "channel")
20+
{
21+
endpointParameterName = "channel";
22+
}
23+
else if (enumValue.ToLowerInvariant() == "channel_custom")
24+
{
25+
endpointParameterName = "channel.custom";
26+
}
27+
else if (enumValue.ToLowerInvariant() == "uuid_custom")
28+
{
29+
endpointParameterName = "uuid.custom";
30+
}
31+
32+
return endpointParameterName;
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)