Detect on/offline status automatically