mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 14:10:49 -05:00
* feat(iot): publish connection lifecycle events The MQTT broker publishes $aws/events/presence/connected and disconnected for every session, with its session identifier, certificate principal, version number and disconnect reason, through topic rules and to subscribers. Topic filters starting with a wildcard no longer match $ topics, as on AWS. Closes #5275 * fix(iot): keep lifecycle events within the reset guard A lifecycle event admits its topic rules under the rule state at the time of the event, so one queued before an emulator reset skips them. A DeleteConnection that wins the session tolerates an endpoint the client's DISCONNECT already closed. * fix(iot): serialize session transitions and report keep-alive timeouts Admission, takeover, DeleteConnection and session end now allocate the versionNumber and change the session map under one lock, with endpoint I/O kept outside it. A takeover of an endpoint that is already closed still accepts the new connection. A close after a full keep-alive period without a packet from the client is reported as MQTT_KEEP_ALIVE_TIMEOUT, as AWS IoT does. The WebSocket upgrade carries the client's port, and the wildcard-first exclusion is limited to the lifecycle topics, which AWS does not deliver to such filters while it does deliver shadow topics. * fix(iot): keep ended sessions out of subscriptions and time keep-alive from CONNECT * test(iot): drive keep-alive tests from an injected nano-time source The broker takes a LongSupplier nano-time source, as ReloadingKeyManager does, so the keep-alive unit tests move a fake clock forward instead of sleeping. The race test uses ThreadStates.awaitBlockedOrDone.