| 322 | } |
| 323 | |
| 324 | void HttpStreamTransport::update(u32 currentTimeMs) { |
| 325 | // Update connection state |
| 326 | mConnection.update(currentTimeMs); |
| 327 | bool nowConnected = isConnected(); |
| 328 | |
| 329 | // Handle state changes |
| 330 | if (mWasConnected != nowConnected) { |
| 331 | handleConnectionStateChange(currentTimeMs); |
| 332 | mWasConnected = nowConnected; |
| 333 | } |
| 334 | |
| 335 | if (!isConnected()) { |
| 336 | // Attempt reconnection if needed |
| 337 | if (mConnection.shouldReconnect()) { |
| 338 | triggerReconnect(); |
| 339 | } |
| 340 | return; |
| 341 | } |
| 342 | |
| 343 | // Send heartbeat if needed |
| 344 | u32 timeSinceLastSent = currentTimeMs - mLastHeartbeatSent; |
| 345 | if (timeSinceLastSent >= mHeartbeatInterval) { |
| 346 | sendHeartbeat(); |
| 347 | } |
| 348 | |
| 349 | // Check for heartbeat timeout |
| 350 | checkHeartbeatTimeout(currentTimeMs); |
| 351 | |
| 352 | // Process incoming data and drain messages (resolves promises) |
| 353 | processIncomingData(); |
| 354 | parseChunkedMessages(); |
| 355 | } |
| 356 | |
| 357 | void HttpStreamTransport::setOnConnect(StateCallback callback) { |
| 358 | mOnConnect = callback; |
nothing calls this directly
no test coverage detected