Skip to content

Commit

Permalink
impl optional message framing TcpServer
Browse files Browse the repository at this point in the history
  • Loading branch information
alec1o committed Jun 30, 2023
1 parent 5bea01a commit f3484d9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Tcp/TcpServers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ namespace Netly
{
public class TcpServer : Server<TcpClient>, IServer<TcpClient>
{
/// <summary>
/// TCP server: Instance
/// </summary>
/// <param name="messageFraming">true: netly will use its own message framing protocol, set false if your server is not netly and you want to communicate with other libraries</param>
public TcpServer(bool messageFraming)
{
MessageFraming = messageFraming;
}

public override void Open(Host host, int backlog)
{
if (IsOpened || m_connecting || m_closing) return;
Expand Down Expand Up @@ -70,7 +79,7 @@ protected override void AcceptOrReceive()

void EndAccept(Socket socket)
{
TcpClient client = new TcpClient(Guid.NewGuid().ToString(), socket);
TcpClient client = new TcpClient(Guid.NewGuid().ToString(), socket, MessageFraming);
AddOrRemoveClient(client, false);

client.OnOpen(() =>
Expand Down

0 comments on commit f3484d9

Please sign in to comment.