| .. | .. |
|---|
| 164 | 164 | _sendCommand('sync', activeId != null ? {'activeSessionId': activeId} : null); |
|---|
| 165 | 165 | // catch_up is sent after sessions arrive (in _handleSessions) |
|---|
| 166 | 166 | }; |
|---|
| 167 | + _ws!.onResume = () { |
|---|
| 168 | + // App came back from background with connection still alive. |
|---|
| 169 | + // Send catch_up to fetch any messages missed during suspend. |
|---|
| 170 | + _chatLog('onResume: sending catch_up with lastSeq=$_lastSeq'); |
|---|
| 171 | + _sendCommand('catch_up', {'lastSeq': _lastSeq}); |
|---|
| 172 | + }; |
|---|
| 167 | 173 | _ws!.onError = (error) { |
|---|
| 168 | 174 | debugPrint('MQTT error: $error'); |
|---|
| 169 | 175 | }; |
|---|