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:EventEngine #215

Merged
merged 120 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from 110 commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
5233fa6
Updated AsyncBridge pkg in project file
budgetpreneur Mar 17, 2023
990491f
EventEngine WIP
budgetpreneur Mar 17, 2023
ac1591f
EventEngine Handshake and Receiving
budgetpreneur Mar 20, 2023
fc832a1
subscribe listeners
budgetpreneur Mar 30, 2023
0230476
ISubscribeOperation for Subscribe
budgetpreneur Mar 30, 2023
8aad1e5
untangled PubnubCoreBase2 for SubscribeOperation2
budgetpreneur Mar 31, 2023
32b8d9b
support pubnubpcl and uwp
budgetpreneur Apr 7, 2023
12095a0
capture last TT for subscribe when network fails
budgetpreneur Apr 7, 2023
a677651
PNStatus
budgetpreneur Apr 12, 2023
a4e009d
EventEngine states and transitions WIP
budgetpreneur Apr 18, 2023
8f46189
unit tests for EE - unsubscribed and handshake
budgetpreneur Apr 18, 2023
28d35f1
WIP
budgetpreneur Apr 20, 2023
a7acb95
Refactored around states and invocations
budgetpreneur Apr 21, 2023
f9b94c2
Replaced EffectInvocationType with EventType
budgetpreneur Apr 21, 2023
b993326
Refactored EffectInvocation and Event
budgetpreneur Apr 21, 2023
479dfe9
Added invocations
budgetpreneur Apr 27, 2023
b0c375f
WIP - ContractTesting
budgetpreneur Apr 28, 2023
5d37592
ContractTest simpleSubscribe
budgetpreneur May 1, 2023
b2ac613
Replaced Tuple with KeyValuePair for EventEngine tests
budgetpreneur May 1, 2023
776bb07
HandshakeReconnect handler
budgetpreneur May 2, 2023
1f9c4e4
Handshake retry attempts
budgetpreneur May 3, 2023
849159c
unit tests for HandshakeReconnecting
budgetpreneur May 5, 2023
9d4247b
Added unit tests to Transitions
budgetpreneur May 8, 2023
559baf9
refactored based on tests
budgetpreneur May 10, 2023
1b4b701
check for timetoken for valid response
budgetpreneur May 10, 2023
e21ffff
Handshakereconnect failure
budgetpreneur May 11, 2023
07e5557
Updated Transitions
budgetpreneur May 12, 2023
1c5ade8
subscribeHandshakeFailure contract test
budgetpreneur May 12, 2023
a31821d
Merge branch 'master' into eventengine-poc
budgetpreneur May 18, 2023
ef8ed07
Removed unused project reference.
budgetpreneur May 19, 2023
0c793ba
Refactored Effect Dispatcher
budgetpreneur May 22, 2023
3666c9d
fix in refactored effect dispatcher
budgetpreneur May 22, 2023
8e49353
Updated dependency nuget packages
budgetpreneur May 22, 2023
fefe815
refactor around dispatcher
budgetpreneur May 23, 2023
f76cd79
unwanted namespace
budgetpreneur May 23, 2023
00d9b9f
fix HandshakeReconnect IsManaged flag
budgetpreneur May 23, 2023
09df4f3
not required code
budgetpreneur May 29, 2023
a437f2b
removed unused dispatch method
budgetpreneur May 29, 2023
58a295e
CancelHandshake
budgetpreneur Jun 1, 2023
189b2c4
CancelReceive and CancelHandshakeReconnect
budgetpreneur Jun 2, 2023
f655009
ReceivingReconnect WIP
budgetpreneur Jun 5, 2023
81e5f0e
ReceivingReconnect
budgetpreneur Jun 12, 2023
41fbe92
PresenceEventResult
budgetpreneur Jun 13, 2023
e1d65ca
Fix to pass contract test
budgetpreneur Jun 13, 2023
84af23d
Eventengine poc refactor (#170)
MikeDobrzan Jun 22, 2023
5b8de6c
added states and Pascal case property names (#171)
budgetpreneur Jun 23, 2023
fd63a9b
HandshakeReconnectingState and other Pascal casing (#172)
budgetpreneur Jun 23, 2023
d62f48b
Null guard on invocation list
MikeDobrzan Jun 23, 2023
de70060
HandshakeStoppedState, ReceiveStoppedState, ReceiveFailedState, Recei…
budgetpreneur Jun 26, 2023
3a944e6
Eventengine/state simplification (#174)
MikeDobrzan Jun 27, 2023
8500c55
file ref fix
budgetpreneur Jun 27, 2023
2fc23b9
fix: simplify and add comments
MikeDobrzan Jul 6, 2023
9a8a054
fix: comments
MikeDobrzan Jul 6, 2023
3d831bb
fix: more comments
MikeDobrzan Jul 6, 2023
b64812e
fix: race condition
MikeDobrzan Jul 6, 2023
8f1e3f3
fix: additional race condition guards
MikeDobrzan Jul 6, 2023
5c0892b
fix: removed unused property
MikeDobrzan Jul 6, 2023
aa2c1c5
fix: made loop generic
MikeDobrzan Jul 6, 2023
8ba35de
feat: simplified abstraction (#176)
MikeDobrzan Jul 10, 2023
40f189c
Merge branch 'master' into eventengine-poc
budgetpreneur Jul 12, 2023
839dda5
UnsubscribeAll Event (#175)
budgetpreneur Jul 17, 2023
6fa332c
Eventengine/handshake handler (#181)
MikeDobrzan Jul 25, 2023
4290809
effect handler cleanup emit status
mohitpubnub Jul 25, 2023
c152648
wip: switch to public
MikeDobrzan Jul 27, 2023
fb431b3
StateTransitions - Tests - WIP
budgetpreneur Jul 28, 2023
9b71539
restore overridden changes from 83d3929
mohitpubnub Jul 31, 2023
796b4b3
csproj ReconnectionConfiguration to PCL/UWP
budgetpreneur Jul 31, 2023
0dc3fcf
Merge remote-tracking branch 'origin/eventengine-poc' into eventengin…
budgetpreneur Jul 31, 2023
0fee497
wip: base class for states
MikeDobrzan Jul 31, 2023
ef0350c
Merge remote-tracking branch 'origin/eventengine-poc' into eventengin…
budgetpreneur Jul 31, 2023
206713b
wip: event engine delegates exposed
MikeDobrzan Jul 31, 2023
3d76790
refactor handshake unit tests
budgetpreneur Jul 31, 2023
3ac2b39
HandshakeFailedState tests
budgetpreneur Jul 31, 2023
6ad3fef
HandshakeStopped tests
budgetpreneur Jul 31, 2023
be00949
ReceivingState tests
budgetpreneur Jul 31, 2023
c1feb74
ReceiveReconnectingState tests
budgetpreneur Jul 31, 2023
f294b0a
ReceiveReconnectingState - more tests
budgetpreneur Jul 31, 2023
d15eabd
ReceiveFaileState and ReceiveStoppedState
budgetpreneur Jul 31, 2023
780cf4d
Any UnsubscribeEvent tests
budgetpreneur Jul 31, 2023
39c21e4
Separated tests to individual states
budgetpreneur Aug 1, 2023
a3297c9
HandshakingState emit status
budgetpreneur Aug 1, 2023
51d8738
invocations and refactor
budgetpreneur Aug 1, 2023
57f4fb2
wip: preliminary potential fix for dispatcher
MikeDobrzan Aug 2, 2023
af2633b
Merge remote-tracking branch 'origin/eventengine-poc' into eventengin…
budgetpreneur Aug 2, 2023
bbcca51
Refactored HandshakeFailedStateTransition
budgetpreneur Aug 2, 2023
1deba67
take-1: integration
mohitpubnub Aug 3, 2023
65e0a9d
listeners
mohitpubnub Aug 3, 2023
3569933
Eventengine/effects abstraction (#184)
MikeDobrzan Aug 3, 2023
87074b8
fix: emitters
mohitpubnub Aug 4, 2023
276590c
state transition unit tests (#182)
budgetpreneur Aug 4, 2023
05806e9
moved subscribe event engine initialisation to subscribeOpertaion
mohitpubnub Aug 7, 2023
34097c5
added cancel reconnect invocations support
MikeDobrzan Aug 7, 2023
5741c2d
fix: retry condition refined
mohitpubnub Aug 7, 2023
5d12d95
Merge branch 'eventengine-poc' into ee/integration
mohitpubnub Aug 7, 2023
8cb735c
State transitions for presence event engine (#203)
Xavrax Feb 19, 2024
9969668
temporary suspend EE acceptance tests to unlock progress (#205)
Xavrax Feb 19, 2024
c88c141
effect invocations used in transitions (#206)
Xavrax Feb 19, 2024
dc36501
presence: effects (#208)
mohitpubnub Mar 5, 2024
3ed93d6
Ee/fix tests (#207)
Xavrax Mar 5, 2024
1dd0966
PresenceEventEngine integration (#209)
mohitpubnub Mar 18, 2024
8789efb
refactor/EE (#210)
mohitpubnub Mar 27, 2024
fafa2e9
CLEN-1787: Event Engine Acceptance Tests (#212)
mohitpubnub Apr 5, 2024
39db39d
Merge branch 'master' into ee/integration
mohitpubnub Apr 5, 2024
f3ed647
fix: build issue of duplicate property in PNConfiguration
mohitpubnub Apr 5, 2024
ae46d6b
removed unncessary property from PNConfiguration
mohitpubnub Apr 9, 2024
6dde6f3
fix: link EE files in PubnubApiUnity.csproj and change C# version to 9.0
jakub-grzesiowski Apr 9, 2024
babc5e7
merge `bugfix/fix-ut` branch update
mohitpubnub Apr 10, 2024
3d823f7
fix test projects build error and ee unit test
mohitpubnub Apr 10, 2024
0a0ed8f
fix: event engine unit tests
mohitpubnub Apr 10, 2024
f7dcbec
take-1: Try fix mockserver request for `TestSubscribeDecryption`
mohitpubnub Apr 10, 2024
c53a273
fix: key mismatch issue for mock request
mohitpubnub Apr 10, 2024
b13e974
encryption test for unencrypted message
mohitpubnub Apr 10, 2024
f3ccdca
hashCode value override for mock Request
mohitpubnub Apr 10, 2024
8cc9c3a
PCL: add mock request and comparision implementation for mockserver
mohitpubnub Apr 10, 2024
8e620f6
PCL:fix value overflow in hash calculation of mock request.
mohitpubnub Apr 10, 2024
c24944c
added EventEmitter implementation to fix emit event effect to redirec…
mohitpubnub Apr 11, 2024
f7e4bfa
Fix MockServer Socket and Requests storing issues, link duplicate fil…
jakub-grzesiowski Apr 16, 2024
1e467d9
revert run test change
mohitpubnub Apr 18, 2024
757c712
Merge branch 'master' into ee/integration
mohitpubnub Apr 18, 2024
d0b057e
PubNub SDK v6.20.0.0 release.
pubnub-release-bot Apr 18, 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: 13 additions & 5 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,20 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
2.1.519
dotnet-version: |
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: Cancel workflow runs for commit on error
if: failure()
uses: ./.github/.release/actions/actions/utils/fast-jobs-failure
Expand Down Expand Up @@ -74,9 +79,12 @@ jobs:
dotnet build --no-restore
- name: Run acceptance tests
env:
PN_PUB_KEY: ${{ secrets.PN_PUB_KEY }}
PN_SUB_KEY: ${{ secrets.PN_SUB_KEY }}
PN_SEC_KEY: ${{ secrets.PN_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 }}
PN_PUB_KEY: ${{ secrets.SDK_PUB_KEY }}
PN_SUB_KEY: ${{ secrets.SDK_SUB_KEY }}
PN_SEC_KEY: ${{ secrets.SDK_SEC_KEY }}
run: |
Copy-Item -Path "${{ github.workspace }}/sdk-specifications/features/access/*" -Destination "${{ github.workspace }}/src/UnitTests/AcceptanceTests/Features" -Recurse
cd ./UnitTests/AcceptanceTests
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ src/Examples/PubnubApiPCL.XamariniMacExample/obj/*
*.suo
src/UnitTests/MockServer/bin/*
src/UnitTests/MockServer/obj/*

src/PNEventEngine/bin/*
src/PNEventEngine/obj/*
src/PNEventEngineUWP/bin/*
src/PNEventEngineUWP/obj/*

# GitHub Actions #
##################
Expand Down
6 changes: 5 additions & 1 deletion src/Api/PubnubApi/Builder/UrlRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PubnubApi.Interface;
using System.Globalization;
using System.Threading.Tasks;
using System.Threading;
Expand Down Expand Up @@ -89,6 +88,11 @@ Uri IUrlRequestBuilder.BuildMultiChannelSubscribeRequest(string requestMethod, s
requestQueryStringParams.Add("filter-expr", UriUtil.EncodeUriComponent(pubnubConfig[pubnubInstanceId].FilterExpression, currentType, false, false, false));
}

if (!requestQueryStringParams.ContainsKey("ee") && pubnubConfig.ContainsKey(pubnubInstanceId) && pubnubConfig[pubnubInstanceId].EnableEventEngine)
{
requestQueryStringParams.Add("ee", "");
}

if (!requestQueryStringParams.ContainsKey("tt"))
{
requestQueryStringParams.Add("tt", timetoken.ToString(CultureInfo.InvariantCulture));
Expand Down
2 changes: 1 addition & 1 deletion src/Api/PubnubApi/ClientNetworkStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private static async Task<bool> CheckSocketConnect<T>(object internetState)
pubnubCallback = state.PubnubCallbacck;
}

PubnubApi.Interface.IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(pubnubConfig, jsonLib, unit, pubnubLog, null, null, "");
IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(pubnubConfig, jsonLib, unit, pubnubLog, null, null, "");
Uri requestUri = urlBuilder.BuildTimeRequest("GET", "", null);
try
{
Expand Down
1 change: 0 additions & 1 deletion src/Api/PubnubApi/EndPoint/Access/AuditOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PubnubApi.Interface;
using System.Threading.Tasks;
using System.Threading;
using System.Net;
Expand Down
1 change: 0 additions & 1 deletion src/Api/PubnubApi/EndPoint/Access/GrantOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PubnubApi.Interface;
using System.Threading.Tasks;
using System.Threading;
using System.Net;
Expand Down
1 change: 0 additions & 1 deletion src/Api/PubnubApi/EndPoint/Access/GrantTokenOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PubnubApi.Interface;
using System.Threading.Tasks;
using System.Threading;
using System.Net;
Expand Down
3 changes: 1 addition & 2 deletions src/Api/PubnubApi/EndPoint/Access/RevokeTokenOperation.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using PubnubApi.Interface;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using PubnubApi.Interface;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using PubnubApi.Interface;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Threading;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using PubnubApi.Interface;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Threading;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using PubnubApi.Interface;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Threading;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using PubnubApi.Interface;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand Down
3 changes: 1 addition & 2 deletions src/Api/PubnubApi/EndPoint/Files/DeleteFileOperation.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using PubnubApi.Interface;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down
3 changes: 1 addition & 2 deletions src/Api/PubnubApi/EndPoint/Files/DownloadFileOperation.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using PubnubApi.Interface;
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using PubnubApi.Interface;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
Expand Down
3 changes: 1 addition & 2 deletions src/Api/PubnubApi/EndPoint/Files/GetFileUrlOperation.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using PubnubApi.Interface;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down
3 changes: 1 addition & 2 deletions src/Api/PubnubApi/EndPoint/Files/ListFilesOperation.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using PubnubApi.Interface;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down
3 changes: 1 addition & 2 deletions src/Api/PubnubApi/EndPoint/Files/PublishFileMessage.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using PubnubApi.Interface;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
Expand Down
3 changes: 1 addition & 2 deletions src/Api/PubnubApi/EndPoint/Files/SendFileOperation.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using PubnubApi.Interface;
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using PubnubApi.Interface;
using System.Threading;
using System.Net;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using PubnubApi.Interface;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using PubnubApi.Interface;
using System.Threading;
using System.Net;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PubnubApi.Interface;
using System.Threading.Tasks;
using System.Threading;
using System.Net;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using PubnubApi.Interface;
using System.Threading;
using System.Net;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using PubnubApi.Interface;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PubnubApi.Interface;
using System.Threading.Tasks;
using System.Threading;
using System.Net;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PubnubApi.Interface;
using System.Threading.Tasks;
using System.Threading;
using System.Net;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PubnubApi.Interface;
using System.Threading.Tasks;
using System.Threading;
using System.Net;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PubnubApi.Interface;
using System.Threading.Tasks;
using System.Threading;
using System.Net;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PubnubApi.Interface;
using System.Threading.Tasks;
using System.Threading;
using System.Net;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using PubnubApi.Interface;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PubnubApi.Interface;
using System.Threading.Tasks;
using System.Threading;
using System.Net;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PubnubApi.Interface;
using System.Threading.Tasks;
using System.Threading;
using System.Net;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PubnubApi.Interface;
using System.Threading.Tasks;
using System.Threading;
using System.Net;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using PubnubApi.Interface;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
Expand Down
1 change: 0 additions & 1 deletion src/Api/PubnubApi/EndPoint/OtherOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PubnubApi.Interface;
using System.Threading.Tasks;
using System.Threading;
using System.Net;
Expand Down
1 change: 0 additions & 1 deletion src/Api/PubnubApi/EndPoint/Presence/GetStateOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PubnubApi.Interface;
using System.Threading.Tasks;
using System.Threading;
using System.Net;
Expand Down
55 changes: 55 additions & 0 deletions src/Api/PubnubApi/EndPoint/Presence/HeartbeatOperation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;

namespace PubnubApi.EndPoint
{
public class HeartbeatOperation : PubnubCoreBase
{
private readonly PNConfiguration config;
private readonly IJsonPluggableLibrary jsonLibrary;
private readonly IPubnubUnitTest unit;
private readonly IPubnubLog pubnubLog;
private readonly TelemetryManager pubnubTelemetryMgr;

public HeartbeatOperation(PNConfiguration pubnubConfig, IJsonPluggableLibrary jsonPluggableLibrary, IPubnubUnitTest pubnubUnit, IPubnubLog log, TelemetryManager telemetryManager, EndPoint.TokenManager tokenManager, Pubnub instance) : base(pubnubConfig, jsonPluggableLibrary, pubnubUnit, log, telemetryManager, tokenManager, instance)
{
config = pubnubConfig;
jsonLibrary = jsonPluggableLibrary;
unit = pubnubUnit;
pubnubLog = log;
pubnubTelemetryMgr = telemetryManager;

PubnubInstance = instance;
}

internal async Task<PNStatus> HeartbeatRequest<T>(string[] channels, string[] channelGroups)
{
PNStatus resp = null;
try {
string presenceState = string.Empty;

if (config.MaintainPresenceState) presenceState = BuildJsonUserState(channels, channelGroups, true);

IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr, null, "");
Uri request = urlBuilder.BuildPresenceHeartbeatRequest("GET", "", channels, channelGroups, presenceState);
RequestState<T> pubnubRequestState = new RequestState<T>();
pubnubRequestState.Channels = channels;
pubnubRequestState.ChannelGroups = channelGroups;
pubnubRequestState.ResponseType = PNOperationType.PNHeartbeatOperation;
pubnubRequestState.TimeQueued = DateTime.Now;

await UrlProcessRequest<T>(request, pubnubRequestState, false).ContinueWith(r => {
resp = r.Result.Item2;
}, TaskContinuationOptions.ExecuteSynchronously).ConfigureAwait(false);
} catch (Exception ex) {
LoggingMethod.WriteToLog(pubnubLog, string.Format(CultureInfo.InvariantCulture, "DateTime {0} HeartbeatOperation=> HeartbeatRequest \n channel(s)={1} \n cg(s)={2} \n Exception Details={3}", DateTime.Now.ToString(CultureInfo.InvariantCulture), string.Join(",", channels.OrderBy(x => x).ToArray()), string.Join(",", channelGroups.OrderBy(x => x).ToArray()), ex), config.LogVerbosity);
return new PNStatus(ex, PNOperationType.PNHeartbeatOperation, PNStatusCategory.PNUnknownCategory, channels, channelGroups);
}
return resp;
}

}
}
Loading
Loading