diff --git a/Networker/Client/Abstractions/IClient.cs b/Networker/Client/Abstractions/IClient.cs index 4f27c9c..2be1605 100644 --- a/Networker/Client/Abstractions/IClient.cs +++ b/Networker/Client/Abstractions/IClient.cs @@ -5,19 +5,70 @@ namespace Networker.Client.Abstractions { public interface IClient { + /// + /// Occurs when the client is connected. + /// EventHandler Connected { get; set; } + + /// + /// Occurs when the client is disconnected. + /// EventHandler Disconnected { get; set; } + /// + /// Serialize and send a Tcp packet. + /// + /// The passed type. + /// The packet. void Send(T packet); - // void Send(byte[] packet); + /// + /// Send a raw byte array via Tcp packet. + /// + /// + /// Keep in mind that Networker Server require the packet header, + /// which is handled by the . + /// + /// So always recommended to use instead. + /// + /// The packet byte array. + void Send(byte[] packet); + + /// + /// Serialize and send a Udp packet. + /// + /// The passed type. + /// The packet. void SendUdp(T packet); + + /// + /// Send a raw byte array via Udp packet. + /// + /// + /// Keep in mind that Networker Server require the packet header, + /// which is handled by the . + /// + /// So always recommended to use instead. + /// + /// The packet byte array. void SendUdp(byte[] packet); + /// + /// Send a ping to the server. + /// + /// The amount of time until timout. + /// Returns -1 if unsuccessful; Otherwise the roundtrip time. long Ping(int timeout = 10000); + /// + /// Connect to the Server. + /// + /// ConnectResult Connect(); + /// + /// Close the connection to the server. + /// void Stop(); } } diff --git a/Networker/Client/Client.cs b/Networker/Client/Client.cs index 5222a94..65517f1 100644 --- a/Networker/Client/Client.cs +++ b/Networker/Client/Client.cs @@ -25,7 +25,10 @@ public class Client : IClient private UdpClient udpClient; private IPEndPoint udpEndpoint; + /// public EventHandler Connected { get; set; } + + /// public EventHandler Disconnected { get; set; } public Client(ClientBuilderOptions options, @@ -96,7 +99,10 @@ public long Ping(int timeout) } /// - public void Send(T packet) => Send(this.packetSerialiser.Serialise(packet)); + public void Send(T packet) + { + Send(this.packetSerialiser.Serialise(packet)); + } /// public void Send(byte[] packet) @@ -110,7 +116,10 @@ public void Send(byte[] packet) } /// - public void SendUdp(T packet) => SendUdp(this.packetSerialiser.Serialise(packet)); + public void SendUdp(T packet) + { + SendUdp(this.packetSerialiser.Serialise(packet)); + } /// public void SendUdp(byte[] packet)