mirror of
https://github.com/thebreaddev/Supercell.GUT.git
synced 2024-11-13 00:54:37 +00:00
ad23f95319
only basic messages, wip.
30 lines
No EOL
732 B
C#
30 lines
No EOL
732 B
C#
using System.Net;
|
|
using System.Net.Sockets;
|
|
|
|
namespace Supercell.GUT.Server.Network.Tcp;
|
|
internal class TcpSocketEntity : IProtocolEntity
|
|
{
|
|
private readonly Socket _socket;
|
|
|
|
public TcpSocketEntity(Socket socket)
|
|
{
|
|
_socket = socket;
|
|
}
|
|
|
|
public EndPoint RemoteEndPoint => _socket.RemoteEndPoint!;
|
|
|
|
public ValueTask<int> ReceiveAsync(Memory<byte> buffer, CancellationToken cancellationToken)
|
|
{
|
|
return _socket.ReceiveAsync(buffer, cancellationToken);
|
|
}
|
|
|
|
public ValueTask<int> SendAsync(Memory<byte> buffer, CancellationToken cancellationToken)
|
|
{
|
|
return _socket.SendAsync(buffer, cancellationToken);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_socket.Close();
|
|
}
|
|
} |