#pragma once

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

#include <memory>

class WinsockSocket;
class WinsockInterface;

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

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

    void shutDown() override;

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

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

    ThreadCollection mThreads;
    onConnectionSuccessFunc mConnectionCallback;
    onConnectionFailedFunc mFailedCallback;

    std::unique_ptr<WinsockInterface> mWinsockInterface;
};
