| 81 | } |
| 82 | |
| 83 | void AFCNetClientService::ProcessUpdate() |
| 84 | { |
| 85 | for (auto iter : real_connections_) |
| 86 | { |
| 87 | auto connection_data = iter.second; |
| 88 | switch (connection_data->net_state_) |
| 89 | { |
| 90 | case AFConnectionData::DISCONNECT: |
| 91 | { |
| 92 | connection_data->net_state_ = AFConnectionData::RECONNECT; |
| 93 | if (connection_data->net_client_ != nullptr) |
| 94 | { |
| 95 | connection_data->net_client_->Shutdown(); |
| 96 | } |
| 97 | } |
| 98 | break; |
| 99 | case AFConnectionData::CONNECTING: |
| 100 | { |
| 101 | if (connection_data->net_client_ != nullptr) |
| 102 | { |
| 103 | connection_data->net_client_->Update(); |
| 104 | } |
| 105 | } |
| 106 | break; |
| 107 | case AFConnectionData::CONNECTED: |
| 108 | { |
| 109 | if (connection_data->net_client_ != nullptr) |
| 110 | { |
| 111 | connection_data->net_client_->Update(); |
| 112 | |
| 113 | KeepAlive(connection_data); |
| 114 | } |
| 115 | } |
| 116 | break; |
| 117 | case AFConnectionData::RECONNECT: |
| 118 | { |
| 119 | // RECONNECT 30s/time |
| 120 | if ((connection_data->last_active_time_ + 30 * AFTimespan::SECOND_MS) >= m_pPluginManager->GetNowTime()) |
| 121 | { |
| 122 | break; |
| 123 | } |
| 124 | |
| 125 | connection_data->last_active_time_ = m_pPluginManager->GetNowTime(); |
| 126 | |
| 127 | if (connection_data->net_client_ != nullptr) |
| 128 | { |
| 129 | connection_data->net_client_->Shutdown(); |
| 130 | } |
| 131 | |
| 132 | // based on protocol to create a new client |
| 133 | bool ret = connection_data->net_client_->StartClient(connection_data->head_len_, |
| 134 | connection_data->server_bus_id_, connection_data->endpoint_.GetIP(), |
| 135 | connection_data->endpoint_.GetPort(), connection_data->endpoint_.IsV6()); |
| 136 | if (!ret) |
| 137 | { |
| 138 | connection_data->net_state_ = AFConnectionData::RECONNECT; |
| 139 | } |
| 140 | else |
nothing calls this directly
no test coverage detected