Disconnecting a Device
API Function
This API is used to disconnect a device from the IoT platform.
API Description
1 | public static boolean logout();
|
Class
LoginService
Return Value
| Return Value | Description |
|---|---|
| true | Success |
| false | Failure |
Return values only show API calling results. For example, the return value true indicates that the API is called successfully but does not indicate that the disconnection is successful. The disconnection is successful only after the LoginService broadcast is received.
Example
Call this API to disconnect a device.
1 | LoginService. logout();
|
Implement the observer API provided by the AgentLite before calling this API.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | public class AgentliteLogin implements MyObserver {
public AgentliteLogin (Observable loginService) {
loginService. registerObserver (this);
}
//Override the update method in the AgentliteLogin.
@Override
public void update(IotaMessage arg0) {
// TODO Auto-generated method stub
System.out.println("LoginManager receives a notification:" + arg0)
int mMsgType = arg0.getMsgType();
switch(mMsgType) {
case 1:
loginResultAction(arg0);
break;
case 2:
logoutResultAction(arg0);
break;
default:
break;
}
}
|
Last Article: Connecting a Device
Next Article: Managing an Indirectly Connected Device
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.