Skip to content
This repository has been archived by the owner on Jul 26, 2021. It is now read-only.

Commit

Permalink
Clean up before pre-release
Browse files Browse the repository at this point in the history
  • Loading branch information
almightylks committed Dec 20, 2020
1 parent c2fc8be commit f40f765
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
22 changes: 17 additions & 5 deletions Client/Connection/EasyClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,33 @@ public void ConnectToHost(IPAddress address, int port)

Connection = new Connection() { IPAddress = address, Port = port };


try
{
Client.Connect(address, port);
logger.Info($"Connection attempt successfull");

var cntArgs = new ConnectedToHostEventArgs() { Connection = Connection, Abort = false };

EventHandler.InvokeConnectedToHost(cntArgs);

if (cntArgs.Abort)
{
DisconnectFromHost();

logger.Info($"Connection attempt aborted");
}
else
{
StartListening();
logger.Info($"Connection attempt successfull");
}
}
catch
{
Connection = null;
logger.Error($"Connection attempt failed");
}

StartListening();
}

/// <summary>
/// Disconnect from <see cref="EasyCommunication.Host.Connection.EasyHost"/>
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions EasyCommunication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<ItemGroup>
<Folder Include="Logging\" />
<Folder Include="Example\" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 4 additions & 3 deletions Events/Client/EventArgs/ConnectedToHostEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.Net.Sockets;
using EasyCommunication.Client.Connection;
using System.Net.Sockets;

namespace EasyCommunication.Events.Client.EventArgs
{
public class ConnectedToHostEventArgs : IClientEventArgs
{
public TcpClient Client { get; internal set; }
public int HostPort { get; internal set; }
public Connection? Connection { get; internal set; }
public bool Abort { get; set; }
}
}

0 comments on commit f40f765

Please sign in to comment.