Skip to content

Commit

Permalink
- removed 'expectedMaxClients'
Browse files Browse the repository at this point in the history
- readme changed
  • Loading branch information
baetz-daniel committed Sep 30, 2020
1 parent 79b3371 commit 22f359f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 23 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class UdpServer : UdpServerEapBase<UdpServerClient>
}

/// <inheritdoc />
public UdpServer(ushort maxClients, ushort maxPacketSize = 65522)
: base(maxClients, maxPacketSize) { }
public UdpServer(ushort maxPacketSize = 65522)
: base(maxPacketSize) { }
}

class UdpServerClient : UdpServerClientBase
Expand All @@ -74,7 +74,7 @@ class UdpServerClient : UdpServerClientBase
```csharp
static void Main(string[] args)
{
using(UdpServer server = new UdpServer(32))
using(UdpServer server = new UdpServer())
{
server.ClientConnected += (server1, client) =>
{
Expand Down Expand Up @@ -154,8 +154,8 @@ class TcpServer : TcpServerEapBase<TcpServerClient>
return true;
}

public TcpServer(ushort expectedMaxClient = 32, ushort maxPacketSize = 65520)
: base(expectedMaxClient, maxPacketSize) { }
public TcpServer(ushort maxPacketSize = 65520)
: base(maxPacketSize) { }
}

class TcpServerClient : TcpServerClientBase
Expand Down Expand Up @@ -188,7 +188,7 @@ static void Main(string[] args)
string request = (string)data;
Console.WriteLine($"Request: {request}");
byte[] buffer = Encoding.UTF8.GetBytes(DateTime.Now.ToLongDateString());
server1.SendTo(client, 45, buffer, 0, buffer.Length, responseid);
server1.SendTo(client, responseid, buffer, 0, buffer.Length, true);
return true;
});

Expand Down
4 changes: 2 additions & 2 deletions examples/Example.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class Server : TcpServerEapBase<ServerClient>
class Server : UdpServerEapBase<ServerClient>
#endif
{
public Server(ushort expectedMaxClient = 32, ushort expectedMaxPayloadSize = 512)
: base(expectedMaxClient, expectedMaxPayloadSize) { }
public Server(ushort expectedMaxPayloadSize = 512)
: base(expectedMaxPayloadSize) { }

protected override bool CreateServerClient(out ServerClient serverClient)
{
Expand Down
2 changes: 0 additions & 2 deletions src/Exomia.Network/TCP/TcpServerApmBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,12 @@ private void AcceptCallback(IAsyncResult ar)
try
{
Socket socket = _listener!.EndAccept(ar);
#pragma warning disable IDE0068 // Use recommended dispose pattern
ServerClientStateObjectApm state = new ServerClientStateObjectApm(
new byte[_payloadSize + Constants.TCP_HEADER_OFFSET],
new CircularBuffer((_payloadSize + Constants.TCP_HEADER_OFFSET) * 2),
new BigDataHandler<int>.Default(),
socket,
new byte[_payloadSize + Constants.TCP_HEADER_OFFSET]);
#pragma warning restore IDE0068 // Use recommended dispose pattern
ReceiveAsync(state);
}
catch (ObjectDisposedException)
Expand Down
6 changes: 2 additions & 4 deletions src/Exomia.Network/TCP/TcpServerEapBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ public abstract class TcpServerEapBase<TServerClient> : TcpServerBase<TServerCli
/// <summary>
/// Initializes a new instance of the <see cref="TcpServerEapBase{TServerClient}" /> class.
/// </summary>
/// <param name="expectedMaxClients"> (Optional) The expected maximum clients. </param>
/// <param name="expectedMaxPayloadSize"> (Optional) Size of the expected maximum payload. </param>
protected TcpServerEapBase(ushort expectedMaxClients = 32,
ushort expectedMaxPayloadSize = Constants.TCP_PAYLOAD_SIZE_MAX)
protected TcpServerEapBase(ushort expectedMaxPayloadSize = Constants.TCP_PAYLOAD_SIZE_MAX)
: base(expectedMaxPayloadSize)
{
_sendEventArgsPool = new SocketAsyncEventArgsPool((ushort)(expectedMaxClients * 32));
_sendEventArgsPool = new SocketAsyncEventArgsPool(0xFF);
}

private void ListenAsync(SocketAsyncEventArgs acceptArgs)
Expand Down
6 changes: 2 additions & 4 deletions src/Exomia.Network/UDP/UdpServerApmBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ public abstract class UdpServerApmBase<TServerClient> : UdpServerBase<TServerCli
/// <summary>
/// Initializes a new instance of the <see cref="UdpServerApmBase{TServerClien}" /> class.
/// </summary>
/// <param name="expectedMaxClients"> The expected maximum clients. </param>
/// <param name="expectedMaxPayloadSize"> (Optional) Size of the expected maximum payload. </param>
protected UdpServerApmBase(ushort expectedMaxClients,
ushort expectedMaxPayloadSize = Constants.UDP_PAYLOAD_SIZE_MAX)
protected UdpServerApmBase(ushort expectedMaxPayloadSize = Constants.UDP_PAYLOAD_SIZE_MAX)
: base(expectedMaxPayloadSize)
{
_serverClientStateObjectPool = new ObjectPool<ServerClientStateObject>((ushort)(expectedMaxClients * 32));
_serverClientStateObjectPool = new ObjectPool<ServerClientStateObject>(0xFF);
}

private void SendDataToCallback(IAsyncResult iar)
Expand Down
8 changes: 3 additions & 5 deletions src/Exomia.Network/UDP/UdpServerEapBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ public abstract class UdpServerEapBase<TServerClient> : UdpServerBase<TServerCli
/// <summary>
/// Initializes a new instance of the <see cref="UdpServerEapBase{TServerClient}" /> class.
/// </summary>
/// <param name="expectedMaxClients"> The expected maximum clients. </param>
/// <param name="expectedMaxPayloadSize"> (Optional) Size of the expected maximum payload. </param>
protected UdpServerEapBase(ushort expectedMaxClients,
ushort expectedMaxPayloadSize = Constants.UDP_PAYLOAD_SIZE_MAX)
protected UdpServerEapBase(ushort expectedMaxPayloadSize = Constants.UDP_PAYLOAD_SIZE_MAX)
: base(expectedMaxPayloadSize)
{
_receiveEventArgsPool = new SocketAsyncEventArgsPool((ushort)(expectedMaxClients * 32));
_sendEventArgsPool = new SocketAsyncEventArgsPool((ushort)(expectedMaxClients * 32));
_receiveEventArgsPool = new SocketAsyncEventArgsPool(0xFF);
_sendEventArgsPool = new SocketAsyncEventArgsPool(0xFF);
}

/// <inheritdoc />
Expand Down

0 comments on commit 22f359f

Please sign in to comment.