Merge branch 'nsc' into dev
This commit is contained in:
commit
6ebd6bcdc0
1 changed files with 21 additions and 3 deletions
|
@ -114,6 +114,18 @@ public class NSClientService extends Service {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
|
super.onCreate();
|
||||||
|
mWakeLock.acquire();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
mWakeLock.release();
|
||||||
|
}
|
||||||
|
|
||||||
public class LocalBinder extends Binder {
|
public class LocalBinder extends Binder {
|
||||||
public NSClientService getServiceInstance() {
|
public NSClientService getServiceInstance() {
|
||||||
return NSClientService.this;
|
return NSClientService.this;
|
||||||
|
@ -182,8 +194,6 @@ public class NSClientService extends Service {
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
dataCounter = 0;
|
dataCounter = 0;
|
||||||
|
|
||||||
NSClientService.mWakeLock.acquire();
|
|
||||||
|
|
||||||
readPreferences();
|
readPreferences();
|
||||||
|
|
||||||
if (!nsAPISecret.equals(""))
|
if (!nsAPISecret.equals(""))
|
||||||
|
@ -221,7 +231,6 @@ public class NSClientService extends Service {
|
||||||
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "No NS URL specified"));
|
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "No NS URL specified"));
|
||||||
MainApp.bus().post(new EventNSClientStatus("Not configured"));
|
MainApp.bus().post(new EventNSClientStatus("Not configured"));
|
||||||
}
|
}
|
||||||
NSClientService.mWakeLock.release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Emitter.Listener onConnect = new Emitter.Listener() {
|
private Emitter.Listener onConnect = new Emitter.Listener() {
|
||||||
|
@ -242,6 +251,15 @@ public class NSClientService extends Service {
|
||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
if (mSocket != null) {
|
if (mSocket != null) {
|
||||||
|
mSocket.off(Socket.EVENT_CONNECT);
|
||||||
|
mSocket.off(Socket.EVENT_DISCONNECT);
|
||||||
|
mSocket.off(Socket.EVENT_PING);
|
||||||
|
mSocket.off("dataUpdate");
|
||||||
|
mSocket.off("announcement");
|
||||||
|
mSocket.off("alarm");
|
||||||
|
mSocket.off("urgent_alarm");
|
||||||
|
mSocket.off("clear_alarm");
|
||||||
|
|
||||||
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "destroy"));
|
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "destroy"));
|
||||||
isConnected = false;
|
isConnected = false;
|
||||||
hasWriteAuth = false;
|
hasWriteAuth = false;
|
||||||
|
|
Loading…
Reference in a new issue