Skip to content
Discussion options

You must be logged in to vote

v3.x

Example Code
  • Your way
    public void Start()
    {
        var server = new TcpServer() | UdpServer();
        
        server.OnEnter((client) =>
        {
            Task.Run(Listen(client));
        });
    }
    
    public async void Listen(TcpClient|UdpClient client)
    {
        List<byte[]> packages = new List<byte[]>();
    
        // this client have internal thread to receive and send package
        // it means: don't have server overhead
        client.OnData(data => packages.Add(data));
    
        while (client.IsOpened)
        {
            if (packages.Count <= 0) continue;
            byte[] package = packages[0];
            packages.RemoveAt(0); // remove used package
            HandlePacket(package);
        }
    }
  • My Way
    var server = new TcpServer() | U…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@alec1o
Comment options

@vanhaodev
Comment options

@alec1o
Comment options

Comment options

You must be logged in to vote
1 reply
@vanhaodev
Comment options

Answer selected by vanhaodev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants