Skip to content

Commit 44ec920

Browse files
committed
RSA ClientConnectionContainer Bugfix
1 parent 36cb178 commit 44ec920

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

Network/ClientConnectionContainer.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,7 @@ public class ClientConnectionContainer : ConnectionContainer, IPacketHandler, ID
9191
/// <param name="ipAddress">The ip address.</param>
9292
/// <param name="port">The port.</param>
9393
internal ClientConnectionContainer(string ipAddress, int port)
94-
: base(ipAddress, port)
95-
{
96-
Initialize();
97-
}
94+
: base(ipAddress, port) { }
9895

9996
/// <summary>
10097
/// Initializes a new instance of the <see cref="ClientConnectionContainer"/> class.
@@ -106,13 +103,12 @@ internal ClientConnectionContainer(TcpConnection tcpConnection, UdpConnection ud
106103
{
107104
this.tcpConnection = tcpConnection;
108105
this.udpConnection = udpConnection;
109-
Initialize();
110106
}
111107

112108
/// <summary>
113109
/// Initializes this instance and starts connecting to the endpoint.
114110
/// </summary>
115-
private void Initialize()
111+
internal void Initialize()
116112
{
117113
reconnectTimer = new Timer();
118114
reconnectTimer.Elapsed += TryToConnect;

Network/ConnectionFactory.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,12 @@ public static async Task<Tuple<UdpConnection, ConnectionResult>> CreateSecureUdp
316316
/// Creates a new instance of a connection container.
317317
/// </summary>
318318
/// <returns>ConnectionContainer.</returns>
319-
public static ClientConnectionContainer CreateClientConnectionContainer(string ipAddress, int port) => new ClientConnectionContainer(ipAddress, port);
319+
public static ClientConnectionContainer CreateClientConnectionContainer(string ipAddress, int port)
320+
{
321+
var clientConnectionContainer = new ClientConnectionContainer(ipAddress, port);
322+
clientConnectionContainer.Initialize();
323+
return clientConnectionContainer;
324+
}
320325

321326
/// <summary>
322327
/// Creates a new instance of a secure-connection container. (RSA Encryption)
@@ -325,7 +330,12 @@ public static async Task<Tuple<UdpConnection, ConnectionResult>> CreateSecureUdp
325330
/// <param name="keySize">The keySize.</param>
326331
/// </summary>
327332
/// <returns>ConnectionContainer.</returns>
328-
public static ClientConnectionContainer CreateSecureClientConnectionContainer(string ipAddress, int port, string publicKey, string privateKey, int keySize = 2048) => new SecureClientConnectionContainer(ipAddress, port, publicKey, privateKey, keySize);
333+
public static ClientConnectionContainer CreateSecureClientConnectionContainer(string ipAddress, int port, string publicKey, string privateKey, int keySize = 2048)
334+
{
335+
var secureClientConnectionContainer = new SecureClientConnectionContainer(ipAddress, port, publicKey, privateKey, keySize);
336+
secureClientConnectionContainer.Initialize();
337+
return secureClientConnectionContainer;
338+
}
329339

330340
/// <summary>
331341
/// Creates a new instance of a connection container.
@@ -338,7 +348,10 @@ public static ClientConnectionContainer CreateClientConnectionContainer(TcpConne
338348
{
339349
if (tcpConnection == null ||!tcpConnection.IsAlive)
340350
throw new ArgumentException("TCP connection must be connected to an endpoint.");
341-
return new ClientConnectionContainer(tcpConnection, udpConnection);
351+
352+
var clientConnectionContainer = new ClientConnectionContainer(tcpConnection, udpConnection);
353+
clientConnectionContainer.Initialize();
354+
return clientConnectionContainer;
342355
}
343356

344357
/// <summary>
@@ -355,7 +368,10 @@ public static ClientConnectionContainer CreateSecureClientConnectionContainer(Tc
355368
{
356369
if (tcpConnection == null || !tcpConnection.IsAlive)
357370
throw new ArgumentException("TCP connection must be connected to an endpoint.");
358-
return new SecureClientConnectionContainer(tcpConnection, udpConnection, publicKey, privateKey, keySize);
371+
372+
var secureClientConnectionContainer = new SecureClientConnectionContainer(tcpConnection, udpConnection, publicKey, privateKey, keySize);
373+
secureClientConnectionContainer.Initialize();
374+
return secureClientConnectionContainer;
359375
}
360376

361377
/// <summary>

Network/Network.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
77
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
88
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
9-
<Version>5.1.0.5</Version>
9+
<Version>5.1.0.6</Version>
1010
<Authors>Thomas Christof</Authors>
1111
<Company>Indie-Dev</Company>
1212
<Description>Network library supporting: TCP, UDP, Bluetooth, RSA, events and objects. Fast and simple, with only 48bit overhead per packet. Send and receive packets with async operations.
@@ -29,8 +29,8 @@ Fork me: https://github.com/Toemsel/Network</Description>
2929
<PackageTags>TCP, UDP, Bluetooth, Network, Events, Async, RSA</PackageTags>
3030
<PackageReleaseNotes>RSA support for .NET Standard 2.0</PackageReleaseNotes>
3131
<NeutralLanguage>en-US</NeutralLanguage>
32-
<AssemblyVersion>5.1.0.5</AssemblyVersion>
33-
<FileVersion>5.1.0.5</FileVersion>
32+
<AssemblyVersion>5.1.0.6</AssemblyVersion>
33+
<FileVersion>5.1.0.6</FileVersion>
3434
</PropertyGroup>
3535
<ItemGroup>
3636
<Compile Remove="packages\**" />

0 commit comments

Comments
 (0)