Skip to content

Commit 943b6fc

Browse files
committed
upgrade nuget packages and light refactoring
1 parent 4018aee commit 943b6fc

5 files changed

Lines changed: 31 additions & 20 deletions

File tree

src/AuthApp/AuthApp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.1.1" />
1313
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
1414
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.1.1" />
15-
<PackageReference Include="NetCoreForce.Client" Version="2.2.0" />
15+
<PackageReference Include="NetCoreForce.Client" Version="2.5.0" />
1616
</ItemGroup>
1717
<ItemGroup>
1818
<Content Include="appsettings*.json" CopyToOutputDirectory="PreserveNewest" />

src/CometD.NetCore.Salesforce/CometD.NetCore.Salesforce.csproj

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<RootNamespace>CometD.NetCore2.Salesforce</RootNamespace>
6-
76
<Description>Event Bus for Salesforce Platform events.</Description>
87
<PackageLicenseUrl>https://github.com/kdcllc/CometD.NetCore.Salesforce/blob/master/LICENSE</PackageLicenseUrl>
98
<PackageProjectUrl>https://github.com/kdcllc/CometD.NetCore.Salesforce</PackageProjectUrl>
@@ -13,7 +12,6 @@
1312
<PackageTags>salesforce, cometd, bayeux</PackageTags>
1413
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1514
<GenerateDocumentationFile>true</GenerateDocumentationFile>
16-
1715
</PropertyGroup>
1816

1917
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@@ -28,12 +26,12 @@
2826
</PropertyGroup>
2927

3028
<ItemGroup>
31-
<PackageReference Include="CometD.NetCore2" Version="1.0.2" />
29+
<PackageReference Include="CometD.NetCore2" Version="1.0.3" />
3230
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.1.1" />
3331
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.1" />
3432
<PackageReference Include="Microsoft.Extensions.Options" Version="2.1.1" />
35-
<PackageReference Include="NetCoreForce.Client" Version="2.2.0" />
36-
<PackageReference Include="Polly" Version="6.1.0" />
33+
<PackageReference Include="NetCoreForce.Client" Version="2.5.0" />
34+
<PackageReference Include="Polly" Version="6.1.2" />
3735
</ItemGroup>
3836

3937
</Project>

src/CometD.NetCore.Salesforce/SalesforceConfiguration.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System.Collections.Generic;
2-
3-
namespace CometD.NetCore.Salesforce
1+
namespace CometD.NetCore.Salesforce
42
{
53
/// <summary>
64
/// Represents the config settings in appsettings.json
@@ -19,7 +17,7 @@ public sealed class SalesforceConfiguration
1917

2018
/// <summary>
2119
/// Url to login to Salesforce
22-
/// https://test.salesforce.com/services/oauth2/authorize or https://login.salesforce.com/services/oauth2/authorize
20+
/// https://test.salesforce.com/services/oauth2/authorize or https://login.salesforce.com/services/oauth2/authorize
2321
/// </summary>
2422
public string LoginUrl { get; set; }
2523

@@ -43,9 +41,11 @@ public sealed class SalesforceConfiguration
4341
/// </summary>
4442
public string CometDUri { get; set; }
4543

44+
/// <summary>
45+
/// Topic or Event Uri
46+
/// </summary>
4647
public string EventOrTopicUri { get; set; }
4748

48-
4949
/// <summary>
5050
/// Salesforce uri for oauth authentication.
5151
/// </summary>
@@ -61,6 +61,9 @@ public sealed class SalesforceConfiguration
6161
/// </summary>
6262
public string CustomEvent { get; set; }
6363

64+
/// <summary>
65+
/// Salesforce ReplayId for specific message.
66+
/// </summary>
6467
public int ReplayId { get; set; }
6568
}
6669
}

src/CometD.NetCore.Salesforce/StreamingClient.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class StreamingClient : IStreamingClient
2626
private readonly ILogger<StreamingClient> _logger;
2727
private readonly IAuthenticationClientProxy _authenticationClient;
2828
private readonly SalesforceConfiguration _options;
29-
29+
3030
// long polling duration
3131
private const int ReadTimeOut = 120 * 1000;
3232

@@ -80,16 +80,18 @@ public void SubscribeTopic(string topicName, IMessageListener listener, long rep
8080
{
8181
#region ArgumentNullExeption
8282
if (null == topicName || (topicName = topicName.Trim()).Length == 0)
83+
{
8384
throw new ArgumentNullException(nameof(topicName));
85+
}
86+
8487
if (null == listener)
88+
{
8589
throw new ArgumentNullException(nameof(listener));
90+
}
8691
#endregion
8792

8893
var channel = _bayeuxClient.GetChannel(topicName,replayId);
89-
if (null != channel)
90-
{
91-
channel.Subscribe(listener);
92-
}
94+
channel?.Subscribe(listener);
9395
}
9496

9597
///<inheritdoc/>
@@ -219,17 +221,15 @@ private void ErrorExtension_ConnectionException(object sender, Exception ex)
219221
/// <param name="message"></param>
220222
private void ErrorExtension_ConnectionError(object sender, string message)
221223
{
222-
223224
// authentication failure
224225
if (message.ToLower() == "403::Handshake denied" ||
225226
message.ToLower() == "403:denied_by_security_policy:create_denied" ||
226227
message.ToLower() == "403::unknown client"
227228
)
228229
{
229-
230230
_logger.LogError($"Handled CometD Exception: {message}");
231231
_logger.LogDebug($"Re-authenticating BayeuxClient...");
232-
// 1. Disconnect
232+
// 1. Disconnect
233233
Disconnect();
234234
_logger.LogDebug($"Disconnecting {nameof(BayeuxClient)}...");
235235
// 2. try (x) times to re-authenticate
@@ -252,12 +252,19 @@ private void ErrorExtension_ConnectionError(object sender, string message)
252252
private bool _isDisposed = false;
253253
private ReplayExtension _replayIdExtension;
254254

255+
/// <summary>
256+
/// Disposing of the resources
257+
/// </summary>
255258
public void Dispose()
256259
{
257260
Dispose(true);
258261
GC.SuppressFinalize(this);
259262
}
260263

264+
/// <summary>
265+
/// Disposing of the resources
266+
/// </summary>
267+
/// <param name="disposing"></param>
261268
protected virtual void Dispose(bool disposing)
262269
{
263270
if (disposing && !_isDisposed)
@@ -267,6 +274,9 @@ protected virtual void Dispose(bool disposing)
267274
}
268275
}
269276

277+
/// <summary>
278+
/// Destructor
279+
/// </summary>
270280
~StreamingClient()
271281
{
272282
Dispose(false);

src/TestApp/TestApp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="CometD.NetCore2" Version="1.0.2" />
11+
<PackageReference Include="CometD.NetCore2" Version="1.0.3" />
1212
<PackageReference Include="KDCLLC.BuildingBlocks.SalesforceEventBus" Version="1.0.2" />
1313
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.1.1" />
1414
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="2.1.1" />

0 commit comments

Comments
 (0)