mirror of
https://github.com/raphaeIl/Novaria.git
synced 2025-12-13 15:04:36 +01:00
serverlist handler + basic crypto, rename project
This commit is contained in:
45
Novaria.GameServer/Protocol/Connection.cs
Normal file
45
Novaria.GameServer/Protocol/Connection.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using Serilog;
|
||||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Novaria.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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user