| 67 | } |
| 68 | |
| 69 | void NetworkClient::onUpdate() |
| 70 | { |
| 71 | processReceivedPackets(); |
| 72 | if (_status == NetworkClientStatus::connecting) |
| 73 | { |
| 74 | if (Platform::getTime() >= _timeout) |
| 75 | { |
| 76 | close(); |
| 77 | Logging::info("Failed to connect to server"); |
| 78 | endStatus("Failed to connect to server"); |
| 79 | } |
| 80 | } |
| 81 | else |
| 82 | { |
| 83 | if (hasTimedOut()) |
| 84 | { |
| 85 | Logging::info("Connection with server timed out"); |
| 86 | close(); |
| 87 | } |
| 88 | else |
| 89 | { |
| 90 | switch (_status) |
| 91 | { |
| 92 | case NetworkClientStatus::connectedSuccessfully: |
| 93 | sendRequestStatePacket(); |
| 94 | _status = NetworkClientStatus::waitingForState; |
| 95 | break; |
| 96 | case NetworkClientStatus::waitingForState: |
| 97 | break; |
| 98 | default: |
| 99 | break; |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | void NetworkClient::processReceivedPackets() |
| 106 | { |