Init commit

This commit is contained in:
raphaeIl
2025-01-08 20:08:36 -05:00
commit f855950370
557 changed files with 233848 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
using Serilog;
using System.IO;
using System.Net.Sockets;
using System.Reflection;
namespace NTR.GameServer.Protocol
{
public class Connection
{
private TcpClient tcpClient;
private BinaryReader reader;
private long sendSequence;
private int messageCount_;
private int sendingMessageCount_;
public static Connection CreateConnection(TcpClient tcpClient)
{
return new Connection(tcpClient);
}
public Connection(TcpClient tcpClient) {
this.tcpClient = tcpClient;
this.reader = new BinaryReader(new StreamReader(tcpClient.GetStream()).BaseStream);
}
public void HandleMessage(TcpClient tcpClient)
{
while (tcpClient.Connected)
{
if (tcpClient.GetStream().DataAvailable)
{
string message = reader.ReadString();
Log.Information($"Received message: {message}");
}
}
tcpClient.Close();
Log.Information("Client Disconnected!");
}
}
}