| 34 | } |
| 35 | |
| 36 | bool NativeHttpClient::connect() { |
| 37 | if (mConnection.getState() == ConnectionState::CLOSED) { |
| 38 | return false; // Permanently closed |
| 39 | } |
| 40 | |
| 41 | // If already connected, return true |
| 42 | if (isConnected()) { |
| 43 | return true; |
| 44 | } |
| 45 | |
| 46 | // Notify connection state machine |
| 47 | mConnection.connect(); |
| 48 | |
| 49 | // Attempt platform-specific connection |
| 50 | if (platformConnect()) { |
| 51 | mConnection.onConnected(0); // TODO: pass actual currentTimeMs |
| 52 | return true; |
| 53 | } |
| 54 | |
| 55 | // Connection failed |
| 56 | mConnection.onDisconnected(); |
| 57 | return false; |
| 58 | } |
| 59 | |
| 60 | void NativeHttpClient::disconnect() { |
| 61 | if (mSocket.is_open()) { |
no test coverage detected