fix NPE in NsClientService

This commit is contained in:
Milos Kozak 2018-08-05 20:46:52 +02:00
parent ff30d9af80
commit 2677f3cca7

View file

@ -248,7 +248,8 @@ public class NSClientService extends Service {
@Override @Override
public void call(Object... args) { public void call(Object... args) {
connectCounter++; connectCounter++;
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "connect #" + connectCounter + " event. ID: " + mSocket.id())); String socketId = mSocket != null ? mSocket.id() : "NULL";
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "connect #" + connectCounter + " event. ID: " + socketId));
sendAuthMessage(new NSAuthAck()); sendAuthMessage(new NSAuthAck());
watchdog(); watchdog();
} }
@ -289,7 +290,7 @@ public class NSClientService extends Service {
} }
}; };
public void destroy() { public synchronized void destroy() {
if (mSocket != null) { if (mSocket != null) {
mSocket.off(Socket.EVENT_CONNECT); mSocket.off(Socket.EVENT_CONNECT);
mSocket.off(Socket.EVENT_DISCONNECT); mSocket.off(Socket.EVENT_DISCONNECT);