markiodev / Networker

A simple to use TCP and UDP networking library for .NET. Compatible with Unity.
MIT License
477 stars 77 forks source link

ClientDisconnected problem #10

Closed SheppeR closed 6 years ago

SheppeR commented 6 years ago

Hi just tested your library and found a issue about this event, ClientDisconnected on server never trigger. There is a second problem, there is no ClientConnected and Close/Disconnect on client side

example:

``

    public ApisServer(string host, int port)
    {
        Host = host;
        Port = port;
        server = new NetworkerServerBuilder()
            .UseIpAddresses(new[] {host}).UseConsoleLogger().UseTcp(port)
            .RegisterPacketHandler<CL_Login, LoginHandler>()
            .Build<DefaultServer>();

        server.ClientConnected += ClientConnected;
        server.ClientDisconnected += ClientDisconnected;
    }

    private void ClientDisconnected(object sender, TcpConnectionDisconnectedEventArgs e)
    {
        Logger.Debug("Client disconnected {0}", e.Connection.Identifier); // Never trigger
    }

    private void ClientConnected(object sender, TcpConnectionConnectedEventArgs e)
    {
        Logger.Debug("Client connected {0}", e.Connection.Identifier);
    }

``

markiodev commented 6 years ago

I have tested the server events and added them to example, they appear to be working. I have also added events for the client.