Detect online/offline events.