本文整理汇总了C++中Network::closeClient方法的典型用法代码示例。如果您正苦于以下问题:C++ Network::closeClient方法的具体用法?C++ Network::closeClient怎么用?C++ Network::closeClient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network::closeClient方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(NetworkTest, testOpenClient)
{
Network network;
ASSERT_TRUE(network.openServer(PORT, &serverListener)) << network.getError();
ASSERT_TRUE(network.openClient(LOCALHOST, PORT, &listener)) << network.getError();
network.closeClient();
network.closeServer();
}
示例2: msgNames
TEST(NetworkTest, testSendStringList)
{
std::vector<std::string> names;
names.push_back("Test1");
names.push_back("Test2");
PlayerListMessage msgNames(names);
Network network;
ASSERT_TRUE(network.openServer(PORT, &serverListener)) << network.getError();
class NetworkNameListTestListener: public IClientCallback {
public:
NetworkNameListTestListener() :
count(0) {
}
int count;
void onData(ByteStream &data) override
{
ASSERT_EQ(protocol::PROTO_PLAYERLIST, data.readByte());
PlayerListMessage msg(data);
ASSERT_EQ("Test1", msg.getList()[0]);
ASSERT_EQ("Test2", msg.getList()[1]);
++count;
}
};
NetworkNameListTestListener nameListener;
ASSERT_TRUE(network.openClient(LOCALHOST, PORT, &nameListener)) << network.getError();
network.update(0);
network.sendToAllClients(msgNames);
network.update(5000);
network.sendToAllClients(msgNames);
network.update(5000);
network.sendToAllClients(msgNames);
network.update(5000);
ASSERT_EQ(3, nameListener.count);
network.closeClient();
network.closeServer();
}