Skip to content

Commit

Permalink
This can sometimes throw on server restart, but the error is not useful.
Browse files Browse the repository at this point in the history
  • Loading branch information
yariplus committed Jun 22, 2016
1 parent 7052d94 commit 286e424
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ private static boolean hasSocket() {
public static void connect() { instance.connectSocket(); }
public static boolean connected() { return hasSocket() && instance.socket.connected(); }
public static boolean disconnected() { return !connected(); }
public static void close() { if (hasSocket()) instance.socket.close(); }
public static void close() {
if (hasSocket()) {
try {
instance.socket.close();
} catch (Exception ignored) {}
}
}

public static void emit(final String event, final JSONObject data, final Ack ack) {
if (connected()) instance.socket.emit(instance.namespace + event, data, new Ack() {
Expand Down

0 comments on commit 286e424

Please sign in to comment.