Hello Schimon (etl al)

> I am working on a news service for XMPP, which sends messages according
> to status.
>
> When JID is offline, service should stop.

Sounds like you would benefit from using PEP (XEP-0163) which accomplishes this. The publisher publishes a PEP event with its new service namespace, and only online entities with a presence subscription, and a corresponding service-detectable feature requesting PEP events with the corresponding news namespace, will receive the event. In this case, there's no need for the service to manually check subscribers and their current online presence.

Best regards,
Peter Waher