Changeset View
Changeset View
Standalone View
Standalone View
source/network/tests/test_Net.h
/* Copyright (C) 2017 Wildfire Games. | /* Copyright (C) 2019 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | for (size_t j = 0; j < clients.size(); ++j) | ||||
return false; | return false; | ||||
return true; | return true; | ||||
} | } | ||||
void connect(CNetServer& server, const std::vector<CNetClient*>& clients) | void connect(CNetServer& server, const std::vector<CNetClient*>& clients) | ||||
{ | { | ||||
TS_ASSERT(server.SetupConnection(PS_DEFAULT_PORT)); | TS_ASSERT(server.SetupConnection(PS_DEFAULT_PORT)); | ||||
for (size_t j = 0; j < clients.size(); ++j) | for (size_t j = 0; j < clients.size(); ++j) | ||||
TS_ASSERT(clients[j]->SetupConnection("127.0.0.1", PS_DEFAULT_PORT)); | TS_ASSERT(clients[j]->SetupConnection("127.0.0.1", PS_DEFAULT_PORT, nullptr)); | ||||
for (size_t i = 0; ; ++i) | for (size_t i = 0; ; ++i) | ||||
{ | { | ||||
// debug_printf("."); | // debug_printf("."); | ||||
for (size_t j = 0; j < clients.size(); ++j) | for (size_t j = 0; j < clients.size(); ++j) | ||||
clients[j]->Poll(); | clients[j]->Poll(); | ||||
if (clients_are_all(clients, NCS_PREGAME)) | if (clients_are_all(clients, NCS_PREGAME)) | ||||
▲ Show 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | void test_rejoin_DISABLED() | ||||
debug_printf("==== Connecting client 2B\n"); | debug_printf("==== Connecting client 2B\n"); | ||||
CGame client2BGame(true); | CGame client2BGame(true); | ||||
CNetClient client2B(&client2BGame, false); | CNetClient client2B(&client2BGame, false); | ||||
client2B.SetUserName(L"bob"); | client2B.SetUserName(L"bob"); | ||||
clients.push_back(&client2B); | clients.push_back(&client2B); | ||||
TS_ASSERT(client2B.SetupConnection("127.0.0.1", PS_DEFAULT_PORT)); | TS_ASSERT(client2B.SetupConnection("127.0.0.1", PS_DEFAULT_PORT, nullptr)); | ||||
for (size_t i = 0; ; ++i) | for (size_t i = 0; ; ++i) | ||||
{ | { | ||||
debug_printf("[%u]\n", client2B.GetCurrState()); | debug_printf("[%u]\n", client2B.GetCurrState()); | ||||
client2B.Poll(); | client2B.Poll(); | ||||
if (client2B.GetCurrState() == NCS_PREGAME) | if (client2B.GetCurrState() == NCS_PREGAME) | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator