#include "broadcast.h"
#include "app.h"
#include <Wt/WServer.h>
#include <Wt/WSound.h>

std::unique_ptr<Wt::WApplication> createApplication(const Wt::WEnvironment& env, Broadcast& server)
{
  return std::make_unique<App>(env, server);
}

int main(int argc, char **argv) {
    Wt::WServer server(argc, argv, WTHTTP_CONFIGURATION);
    Broadcast chatServer(&server);
    server.addEntryPoint(Wt::EntryPointType::Application,
                         std::bind(createApplication, std::placeholders::_1,
                                     std::ref(chatServer)));
    if (server.start()) {
        int sig = Wt::WServer::waitForShutdown();
        std::cerr << "Shutting down: (signal = " << sig << ")" << std::endl;
        server.stop();
    }
    return 0;
}
