Skip to content

Commit

Permalink
fix acceptance tests errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitpubnub committed Oct 7, 2024
1 parent cea4ff6 commit 4c2ad9e
Show file tree
Hide file tree
Showing 11 changed files with 419 additions and 626 deletions.
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
* @mohitpubnub @xavrax @marcin-cebo
README.md @techwritermat @kazydek @mohitpubnub @xavrax
* @mohitpubnub @xavrax @marcin-cebo @jakub-grzesiowski
README.md @techwritermat @kazydek @mohitpubnub @xavrax @jakub-grzesiowski
1 change: 0 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.x
5.0.x
6.0.x
7.0.x
Expand Down
7 changes: 4 additions & 3 deletions src/Api/PubnubApi/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
namespace PubnubApi
namespace PubnubApi
{
public static class Constants
{
Expand All @@ -10,6 +9,8 @@ public static class Constants
public const string PATCH = "PATCH";
public const string PUT = "PUT";
public const string DELETE = "DELETE";

public const int ResourceNotFoundStatusCode = 404;
public const int HttpRequestSuccessStatusCode = 200;
}
}

1 change: 1 addition & 0 deletions src/Api/PubnubApi/EndPoint/Presence/HeartbeatOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ internal async Task<PNStatus> HeartbeatRequest<T>(string[] channels, string[] ch
var transportResponse = await PubnubInstance.transportMiddleware.Send(transportRequest: transportRequest);
if (transportResponse.Error == null) {
var responseString = Encoding.UTF8.GetString(transportResponse.Content);
pubnubRequestState.GotJsonResponse = true;
PNStatus errorStatus = GetStatusIfError(pubnubRequestState, responseString);
if (errorStatus == null) {
responseStatus = new StatusBuilder(config, jsonLibrary).CreateStatusResponse(pubnubRequestState.ResponseType, PNStatusCategory.PNAcknowledgmentCategory, pubnubRequestState, (int)HttpStatusCode.OK, null);
Expand Down
1 change: 1 addition & 0 deletions src/Api/PubnubApi/EndPoint/Presence/LeaveOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ internal async Task<PNStatus> LeaveRequest<T>(string[] channels, string[] channe
var transportResponse = await PubnubInstance.transportMiddleware.Send(transportRequest: transportRequest);
if (transportResponse.Error == null) {
var responseString = Encoding.UTF8.GetString(transportResponse.Content);
pubnubRequestState.GotJsonResponse = true;
PNStatus errorStatus = GetStatusIfError(pubnubRequestState, responseString);
if (errorStatus == null) {
responseStatus = new StatusBuilder(config, jsonLibrary).CreateStatusResponse(pubnubRequestState.ResponseType, PNStatusCategory.PNAcknowledgmentCategory, pubnubRequestState, (int)HttpStatusCode.OK, null);
Expand Down
1 change: 1 addition & 0 deletions src/Api/PubnubApi/EndPoint/Presence/SetStateOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ private async Task<PNResult<PNSetStateResult>> SharedSetUserState(string[] chann
if (transportResponse.Error == null) {
var responseString = Encoding.UTF8.GetString(transportResponse.Content);
PNStatus errorStatus = GetStatusIfError(requestState, responseString);
requestState.GotJsonResponse = true;
if (errorStatus == null) {
PNStatus status = new StatusBuilder(config, jsonLibrary).CreateStatusResponse(requestState.ResponseType, PNStatusCategory.PNAcknowledgmentCategory, requestState, (int)HttpStatusCode.OK, null);
JsonAndStatusTuple = new Tuple<string, PNStatus>(responseString, status);
Expand Down
1 change: 1 addition & 0 deletions src/Api/PubnubApi/EndPoint/Presence/WhereNowOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ internal async Task<PNResult<PNWhereNowResult>> WhereNow(string uuid, Dictionary
var transportResponse = await PubnubInstance.transportMiddleware.Send(transportRequest: transportRequest);
if (transportResponse.Error == null) {
var responseString = Encoding.UTF8.GetString(transportResponse.Content);
requestState.GotJsonResponse = true;
PNStatus errorStatus = GetStatusIfError(requestState, responseString);
if (errorStatus == null) {
PNStatus status = new StatusBuilder(config, jsonLibrary).CreateStatusResponse(requestState.ResponseType, PNStatusCategory.PNAcknowledgmentCategory, requestState, (int)HttpStatusCode.OK, null);
Expand Down
995 changes: 402 additions & 593 deletions src/Api/PubnubApi/EndPoint/PubSub/SubscribeManager2.cs

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions src/Api/PubnubApi/EndPoint/PubSub/UnsubscribeAllOperation.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.Threading;
using System.Collections.Concurrent;
using System.Threading.Tasks;

namespace PubnubApi.EndPoint
{
Expand Down Expand Up @@ -34,22 +33,13 @@ public UnsubscribeAllOperation<T> QueryParam(Dictionary<string, object> customQu

private void UnsubscribeAll()
{
#if NETFX_CORE || WINDOWS_UWP || UAP || NETSTANDARD10 || NETSTANDARD11 || NETSTANDARD12
Task.Factory.StartNew(() =>
{
SubscribeManager manager = new SubscribeManager(config, jsonLibrary, unit, pubnubLog, pubnubTokenMgr, PubnubInstance);
manager.CurrentPubnubInstance(PubnubInstance);
manager.MultiChannelUnSubscribeAll<T>(PNOperationType.PNUnsubscribeOperation, this.queryParam);
}, CancellationToken.None, TaskCreationOptions.PreferFairness, TaskScheduler.Default).ConfigureAwait(false);
#else
new Thread(() =>
{
SubscribeManager manager = new SubscribeManager(config, jsonLibrary, unit, pubnubLog, pubnubTokenMgr, PubnubInstance);
manager.CurrentPubnubInstance(PubnubInstance);
manager.MultiChannelUnSubscribeAll<T>(PNOperationType.PNUnsubscribeOperation, this.queryParam);
})
{ IsBackground = true }.Start();
#endif
}

internal void CurrentPubnubInstance(Pubnub instance)
Expand Down
10 changes: 0 additions & 10 deletions src/Api/PubnubApi/EndPoint/PubSub/UnsubscribeOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using PubnubApi.Interface;

namespace PubnubApi.EndPoint
Expand Down Expand Up @@ -64,22 +63,13 @@ private void Unsubscribe(string[] channels, string[] channelGroups)

LoggingMethod.WriteToLog(pubnubLog, string.Format(CultureInfo.InvariantCulture, "DateTime {0}, requested unsubscribe for channel(s)={1}, cg(s)={2}", DateTime.Now.ToString(CultureInfo.InvariantCulture), channel, channelGroup), config.LogVerbosity);

#if NETFX_CORE || WINDOWS_UWP || UAP || NETSTANDARD10 || NETSTANDARD11 || NETSTANDARD12
Task.Factory.StartNew(() =>
{
SubscribeManager manager = new SubscribeManager(config, jsonLibrary, unit, pubnubLog, pubnubTokenMgr, PubnubInstance);
manager.CurrentPubnubInstance(PubnubInstance);
manager.MultiChannelUnSubscribeInit<T>(PNOperationType.PNUnsubscribeOperation, channel, channelGroup, this.queryParam);
}, CancellationToken.None, TaskCreationOptions.PreferFairness, TaskScheduler.Default).ConfigureAwait(false);
#else
new Thread(() =>
{
SubscribeManager manager = new SubscribeManager(config, jsonLibrary, unit, pubnubLog, pubnubTokenMgr, PubnubInstance);
manager.CurrentPubnubInstance(PubnubInstance);
manager.MultiChannelUnSubscribeInit<T>(PNOperationType.PNUnsubscribeOperation, channel, channelGroup, this.queryParam);
})
{ IsBackground = true }.Start();
#endif
}

internal void CurrentPubnubInstance(Pubnub instance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ public override async Task Run(ReceiveMessagesInvocation invocation)

switch (invocation)
{
case Invocations.ReceiveReconnectInvocation reconnectInvocation when response.Item2.Error:
eventQueue.Enqueue(new Events.ReceiveReconnectFailureEvent() { AttemptedRetries = (reconnectInvocation.AttemptedRetries + 1) % int.MaxValue, Status = response.Item2});
case ReceiveReconnectInvocation reconnectInvocation when response.Item2.Error:
eventQueue.Enqueue(new ReceiveReconnectFailureEvent() { AttemptedRetries = (reconnectInvocation.AttemptedRetries + 1) % int.MaxValue, Status = response.Item2});
break;
case Invocations.ReceiveReconnectInvocation reconnectInvocation:
eventQueue.Enqueue(new Events.ReceiveReconnectSuccessEvent() { Channels = invocation?.Channels, ChannelGroups = invocation?.ChannelGroups, Cursor = cursor, Status = response.Item2, Messages = response.Item1 });
case ReceiveReconnectInvocation reconnectInvocation:
eventQueue.Enqueue(new ReceiveReconnectSuccessEvent() { Channels = invocation?.Channels, ChannelGroups = invocation?.ChannelGroups, Cursor = cursor, Status = response.Item2, Messages = response.Item1 });
break;
case { } when response.Item2.Error:
eventQueue.Enqueue(new Events.ReceiveFailureEvent() { Cursor = invocation.Cursor, Status = response.Item2, AttemptedRetries = 0});
eventQueue.Enqueue(new ReceiveFailureEvent() { Cursor = invocation.Cursor, Status = response.Item2, AttemptedRetries = 0});
break;
case { }:
eventQueue.Enqueue(new Events.ReceiveSuccessEvent() { Channels = invocation?.Channels, ChannelGroups = invocation?.ChannelGroups, Cursor = cursor, Messages= response.Item1, Status = response.Item2 });
eventQueue.Enqueue(new ReceiveSuccessEvent() { Channels = invocation?.Channels, ChannelGroups = invocation?.ChannelGroups, Cursor = cursor, Messages= response.Item1, Status = response.Item2 });
break;
}
}
Expand All @@ -58,7 +58,7 @@ public override bool IsBackground(ReceiveMessagesInvocation invocation)
return true;
}

private async Task<System.Tuple<ReceivingResponse<object>, PNStatus>> MakeReceiveMessagesRequest(ReceiveMessagesInvocation invocation)
private async Task<Tuple<ReceivingResponse<object>, PNStatus>> MakeReceiveMessagesRequest(ReceiveMessagesInvocation invocation)
{
return await manager.ReceiveRequest<ReceivingResponse<object>>(
PNOperationType.PNSubscribeOperation,
Expand Down

0 comments on commit 4c2ad9e

Please sign in to comment.