Skip to content

Commit

Permalink
set the default value on the host instance in the tcp and udp pro…
Browse files Browse the repository at this point in the history
…perties, this avoids null references. the default value is ``0.0.0.0:0``
  • Loading branch information
alec1o committed Dec 16, 2023
1 parent 7db293a commit 45fad4c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Abstract/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public abstract class Client : IClient

public bool Framing { get; protected set; }
public string UUID { get; protected set; }
public Host Host { get; protected set; }
public Host Host { get; protected set; } = Host.Default;

public bool IsOpened => IsConnected();

Expand Down
2 changes: 1 addition & 1 deletion src/Abstract/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public abstract class Server<T>
{
#region Props
public bool Framing { get; protected set; }
public Host Host { get; protected set; }
public Host Host { get; protected set; } = Host.Default;
public List<T> Clients { get; protected set; } = new List<T>();
public bool IsOpened => IsConnected();

Expand Down
3 changes: 1 addition & 2 deletions src/Udp/UdpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class UdpClient : IUdpClient
/// <summary>
/// Host container
/// </summary>
public Host Host { get; private set; }
public Host Host { get; private set; } = Host.Default;

/// <summary>
/// Return true when connection is enabled (using ping)
Expand Down Expand Up @@ -69,7 +69,6 @@ public UdpClient(bool useConnection, int timeout = _DEFAULT_TIMEOUT_VALUE)
_opened = false;
_serverside = false;
_socket = null;
Host = new Host(IPAddress.Loopback, 0);
Init();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Udp/UdpServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class UdpServer : IUdpServer
/// <summary>
/// Host container
/// </summary>
public Host Host { get; private set; }
public Host Host { get; private set; } = Host.Default;

/// <summary>
/// Connection timeout
Expand Down

0 comments on commit 45fad4c

Please sign in to comment.