| 264 | } |
| 265 | |
| 266 | void 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 | |
| 303 | void AFCNetClientService::OnNetMsg(const AFNetMsg* msg) |
| 304 | { |
nothing calls this directly
no test coverage detected