Skip to content

Commit

Permalink
Merge branch 'TransportLayer' into ci-ut-fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
jakub-grzesiowski authored Oct 3, 2024
2 parents e9e25b9 + 832f659 commit 195c5ee
Show file tree
Hide file tree
Showing 113 changed files with 16,018 additions and 15,904 deletions.
2 changes: 1 addition & 1 deletion .pubnub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1644,4 +1644,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
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
7 changes: 7 additions & 0 deletions src/Api/PubnubApi/Builder/UriUtil.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

namespace PubnubApi
Expand Down Expand Up @@ -196,5 +198,10 @@ 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];
}

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());
}
}
}
28 changes: 4 additions & 24 deletions src/Api/PubnubApi/Builder/UrlRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,29 @@
using System.Linq;
using System.Text;
using System.Globalization;
using System.Threading.Tasks;
using System.Threading;
using PubnubApi.Security.Crypto.Common;
#if !NETSTANDARD10 && !NETSTANDARD11 && !NETSTANDARD12 && !WP81
using System.Reflection;
#endif
#if !NET35 && !NET40
using System.Collections.Concurrent;
#endif
using PubnubApi.Security.Crypto;
using PubnubApi.Security.Crypto.Cryptors;
using System.Collections.Concurrent;
using System.Reflection;

namespace PubnubApi
{
public sealed class UrlRequestBuilder : IUrlRequestBuilder
public sealed class UrlRequestBuilder : IUrlRequestBuilder
{
private ConcurrentDictionary<string, PNConfiguration> pubnubConfig { get; } = new ConcurrentDictionary<string, PNConfiguration>();
private readonly IJsonPluggableLibrary jsonLib ;
private readonly IPubnubUnitTest pubnubUnitTest;
private readonly IPubnubLog pubnubLog;
private readonly string pubnubInstanceId;
private readonly EndPoint.TelemetryManager telemetryMgr;
private readonly EndPoint.TokenManager tokenMgr;

public UrlRequestBuilder(PNConfiguration config, IJsonPluggableLibrary jsonPluggableLibrary, IPubnubUnitTest pubnubUnitTest, IPubnubLog log, EndPoint.TelemetryManager pubnubTelemetryMgr, EndPoint.TokenManager pubnubTokenMgr, string pnInstanceId)
public UrlRequestBuilder(PNConfiguration config, IJsonPluggableLibrary jsonPluggableLibrary, IPubnubUnitTest pubnubUnitTest, IPubnubLog log, EndPoint.TokenManager pubnubTokenMgr, string pnInstanceId)
{
pubnubConfig.AddOrUpdate(pnInstanceId, config, (k, o) => config);
this.jsonLib = jsonPluggableLibrary;
this.pubnubUnitTest = pubnubUnitTest;
this.pubnubLog = log;
this.telemetryMgr = pubnubTelemetryMgr;
this.tokenMgr = pubnubTokenMgr;
this.pubnubInstanceId = string.IsNullOrEmpty(pnInstanceId) ? "" : pnInstanceId;
}
Expand Down Expand Up @@ -2073,18 +2065,6 @@ private Dictionary<string, string> GenerateCommonQueryParams(PNOperationType typ
ret.Add("instanceid", pubnubInstanceId);
}

if (pubnubConfig.ContainsKey(pubnubInstanceId) && pubnubConfig[pubnubInstanceId].EnableTelemetry && telemetryMgr != null)
{
Dictionary<string, string> opsLatency = telemetryMgr.GetOperationsLatency().ConfigureAwait(false).GetAwaiter().GetResult();
if (opsLatency != null && opsLatency.Count > 0)
{
foreach (string key in opsLatency.Keys)
{
ret.Add(key, opsLatency[key]);
}
}
}

if (pubnubConfig.ContainsKey(pubnubInstanceId) && !string.IsNullOrEmpty(pubnubConfig[pubnubInstanceId].SecretKey))
{
ret.Add("timestamp", timeStamp.ToString(CultureInfo.InvariantCulture));
Expand Down
Loading

0 comments on commit 195c5ee

Please sign in to comment.