MCPcopy Create free account
hub / github.com/OpenArkStudio/ARK / ProcessAddConnection

Method ProcessAddConnection

src/plugin/net/src/AFCNetClientService.cpp:266–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264}
265
266void AFCNetClientService::ProcessAddConnection()
267{
268 for (auto& iter : tmp_connections_)
269 {
270 const AFConnectionData& connection_data = iter;
271 std::shared_ptr<AFConnectionData> target_connection_data =
272 real_connections_.find_value(connection_data.server_bus_id_);
273 if (target_connection_data != nullptr)
274 {
275 continue;
276 }
277 // add new server
278 target_connection_data = std::make_shared<AFConnectionData>();
279
280 *target_connection_data = connection_data;
281 target_connection_data->last_active_time_ = m_pPluginManager->GetNowTime();
282
283 // based on protocol to create a new client
284 target_connection_data->net_client_ = CreateNet(target_connection_data->endpoint_.proto());
285 int ret = target_connection_data->net_client_->StartClient(target_connection_data->head_len_,
286 target_connection_data->server_bus_id_, target_connection_data->endpoint_.GetIP(),
287 target_connection_data->endpoint_.GetPort());
288 if (!ret)
289 {
290 target_connection_data->net_state_ = AFConnectionData::RECONNECT;
291 }
292 else
293 {
294 target_connection_data->net_state_ = AFConnectionData::CONNECTING;
295 }
296
297 real_connections_.insert(target_connection_data->server_bus_id_, target_connection_data);
298 }
299
300 tmp_connections_.clear();
301}
302
303void AFCNetClientService::OnNetMsg(const AFNetMsg* msg)
304{

Callers

nothing calls this directly

Calls 7

protoMethod · 0.80
GetPortMethod · 0.80
find_valueMethod · 0.45
GetNowTimeMethod · 0.45
StartClientMethod · 0.45
insertMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected