Exemple #1
0
int main(int argc, char * argv[]) {
	ServerManager * servBoss;
	Client testClient;
	Client testClient2;
	Account toddAccount("Todd", "MyPassword", "127.0.0.1", "*****@*****.**", true);
	Account willAccount("Will", "HisPassword", "127.0.0.1", "*****@*****.**", true);
	Account jonAccount("Jon", "TurtleFarts", "127.0.0.1", "*****@*****.**", true);
	Account hardikaAccount("Hardika", "Kolaches", "127.0.0.1", "*****@*****.**", true);

	servBoss = servBoss->get();
        servBoss->registerClientManager();

        servBoss->AddAccount( toddAccount );
        servBoss->AddAccount( willAccount );
        servBoss->AddAccount( jonAccount );
        servBoss->AddAccount( hardikaAccount );

	servBoss->acquireClient(testClient);
	servBoss->acquireClient(testClient2);

        servBoss->setRunning();

        cout << "H@x0rZ! Server is up and running on default port 9999" << endl;
        cout << "Server Initialization success is " << (servBoss->isRunning()? "True" : "False") << endl;

	GameLoop( *servBoss );

	return 0;
}
Server* Server::get_server(util::Address addr, Proxy*)
{
    static ServerManager server_manager([](Server* s) { delete s; });
    Server* s = server_manager.get(addr, []() { return new Server; });
    s->addr = addr;
    ::created.insert(s);
    return s;
}
void ServerManager::newConnectionThreadWrapper(int clientID) {
	ServerManager * sm = sm->get();
	sm->threadNewConnection(clientID);
}