int main() { if( init() ) { register_packets(); MyServer server; DistManager::SetOwner(server); if( server.start("localhost", 2000) ) { while(!server.quit) { server.update(1000); } server.stop(); server.update(1000); } } }
int _tmain(int argc, _TCHAR* argv[]) { MyServer server; server.registerService(WebsocketOpt, new WebsocketService, "WebService"); server.setClientFactory(new MyClientFactory); server.setMaxConnections(100); server.setLoginExpiryDuration(60); server.setProtocol(new MyProtocol); server.createListener(81); try { server.start(true); } catch (std::exception& e) { cout << "Failed to start server. Exception : " << e.what() << std::endl; return 0; } while (true) { char ch; cin >> ch; if (ch == 'q') { break; } } server.stop(); return 0; }