Skip to content

Commit 16d0013

Browse files
AmbratolmAmbratolm
Ambratolm
authored and
Ambratolm
committedJun 23, 2021
First Commit
0 parents  commit 16d0013

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+965
-0
lines changed
 

‎Client/Client API/Client.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+

2+
namespace Client
3+
{
4+
public static class Client
5+
{
6+
private static TcpClientLite _client;
7+
8+
public static void CreateTcpClient(string ip, int port)
9+
{
10+
_client = new TcpClientLite(ip, port);
11+
ClientLog.ClientCreated(ip, port);
12+
}
13+
14+
public static void Connect(string ip, int port)
15+
{
16+
_client.Connect(ip, port);
17+
ClientLog.ClientConnected(_client.LocalIP, _client.LocalPort,
18+
_client.RemoteIP, _client.RemotePort);
19+
}
20+
21+
public static void SendText(string text)
22+
{
23+
int size = _client.SendText(text);
24+
ClientLog.BytesSent(size);
25+
}
26+
27+
public static void Close()
28+
{
29+
_client.Close();
30+
ClientLog.ClientClosed();
31+
}
32+
}
33+
}

‎Client/Client API/ClientLog.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using SharedAPI;
2+
3+
namespace Client
4+
{
5+
public static class ClientLog
6+
{
7+
public static void New()
8+
{
9+
Log.New("Client");
10+
Log.Header("♦ Client");
11+
}
12+
13+
public static void ClientCreated(string ip, int port)
14+
{
15+
Log.Note("New client created as Client@{0}:{1}.", ip, port);
16+
Log.Warning("Connecting...");
17+
}
18+
19+
public static void ClientConnected(string localIP, int localPort,
20+
string remoteIP, int remotePort)
21+
{
22+
Log.SetCursorToPreviousLine();
23+
Log.ClearLine();
24+
Log.Success("Client@{0}:{1} connected to Server@{2}:{3}.",
25+
localIP, localPort, remoteIP, remotePort);
26+
}
27+
28+
public static void BytesSent(int size)
29+
{
30+
Log.Info("{0} bytes sent.", size);
31+
}
32+
33+
public static void ClientClosed()
34+
{
35+
Log.Warning("Client closed.");
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)