本文整理汇总了C++中ChatClient::push方法的典型用法代码示例。如果您正苦于以下问题:C++ ChatClient::push方法的具体用法?C++ ChatClient::push怎么用?C++ ChatClient::push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChatClient
的用法示例。
在下文中一共展示了ChatClient::push方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv) {
std::string input;
std::string rest;
ChatServer* server = NULL;
ChatClient* client = NULL;
if (SDL_Init(0) == -1) {
std::cerr << "SDL_Init: " << SDL_GetError() << std::endl;
return 1;
}
if (SDLNet_Init() == -1) {
std::cerr << "SDLNet_Init: " << SDLNet_GetError() << std::endl;
return 1;
}
switch (argc) {
case 2:
server = new ChatServer((unsigned short)(atoi(argv[1])));
while (true) {
getline(std::cin, input);
if (input == "quit") {
server->push(new LogoutRequest());
break;
}
}
delete server;
break;
case 3:
std::cout << "Username: ";
getline(std::cin, input);
client = new ChatClient(argv[1], (unsigned short)(atoi(argv[2])));
client->push(new LoginRequest(input));
while (client->isOnline()) {
getline(std::cin, input);
if (!client->authed) { continue; }
if (input == "quit") {
client->push(new LogoutRequest());
} else {
client->push(new MessageRequest(input));
}
}
delete client;
break;
default:
std::cout << "Usage:" << std::endl
<< "\tdemo hostname port\t(start client)" << std::endl
<< "\tdemo port\t\t(start server)" << std::endl;
}
SDLNet_Quit();
SDL_Quit();
}