This commit is contained in:
hyb1996 2017-07-09 08:36:23 +08:00
parent 32e07c6951
commit 077612fa05
2 changed files with 11 additions and 3 deletions

View File

@ -35,7 +35,7 @@ public class SublimePluginClient {
}
}
private Socket mSocket;
private volatile Socket mSocket;
private Handler mResponseHandler;
private String host;
private int port;
@ -73,6 +73,10 @@ public class SublimePluginClient {
}).start();
}
public boolean isListening() {
return mSocket != null;
}
private void tryClose() {
try {
close();

View File

@ -13,7 +13,7 @@ public class SublimePluginService {
private static SublimePluginClient client;
public static boolean isConnected() {
return client != null;
return client != null && client.isListening();
}
public static void disconnectIfNeeded() {
@ -44,6 +44,10 @@ public class SublimePluginService {
JsonObject object = new JsonObject();
object.addProperty("type", "log");
object.addProperty("log", log);
client.send(object);
try {
client.send(object);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
}