#pragma once

#include "PlatformSocketServer.h"
#include "ThreadCollection.h"

#include <memory>

class BerkeleySocket;

class UnixSocketServer : public PlatformSocketServer
{
public:
    virtual ~UnixSocketServer();

    void listen(const Address& address, onConnectionSuccessFunc connectionSuccessFunc, onConnectionFailedFunc connectionFailedFunc) override;

    void shutDown() override;

private:
    void onConnection(std::unique_ptr<BerkeleySocket> clientHandle);

    void onThreadComplete(std::thread::id id);

    ThreadCollection mThreads;
    onConnectionSuccessFunc mConnectionCallback;
    onConnectionFailedFunc mFailedCallback;
};
