add api function to go online/offline