예제 #1
0
파일: server.cpp 프로젝트: dennis/dnet
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 main(){
    MyServer* s = MyServer::createMyServer(8090);
    s->start();

    std::vector<MyClient*> vec;
    //vec.reserve(MAX);
    for (int i=0; i< MAX; i++){
        vec.push_back(MyClient::createMyClient("127.0.0.1", 8090));
        vec[i]->start();
    }

    ThreadBase::sleep(10000);
    tlog("Test finished!");
    for (int i=0; i<MAX; i++){
        vec[i]->destroy();
        delete vec[i];
    }
    s->destroy();
    delete s;
}
예제 #3
0
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;
}