本文整理汇总了C++中MyServer::start方法的典型用法代码示例。如果您正苦于以下问题:C++ MyServer::start方法的具体用法?C++ MyServer::start怎么用?C++ MyServer::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyServer
的用法示例。
在下文中一共展示了MyServer::start方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
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);
}
}
}
示例2: main
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: _tmain
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;
}