Commit 8e235f66 authored by Yusuke Iwaki's avatar Yusuke Iwaki

add error handling for "already closed"

parent a0d5c1cb
......@@ -15,7 +15,8 @@ public class DDPClientCallback {
public static abstract class BaseException extends Exception {
public DDPClient client;
public BaseException(DDPClient client) {
public BaseException(Class<? extends BaseException> clazz, DDPClient client) {
super(clazz.getName());
this.client = client;
}
}
......@@ -32,14 +33,14 @@ public class DDPClientCallback {
public String version;
public Failed(DDPClient client, String version) {
super(client);
super(Failed.class, client);
this.version = version;
}
}
public static class Timeout extends BaseException {
public Timeout(DDPClient client) {
super(client);
super(Timeout.class, client);
}
}
}
......@@ -54,7 +55,7 @@ public class DDPClientCallback {
public static class Timeout extends BaseException {
public Timeout(DDPClient client) {
super(client);
super(Timeout.class, client);
}
}
}
......@@ -74,7 +75,7 @@ public class DDPClientCallback {
public JSONObject error;
public Error(DDPClient client, String id, JSONObject error) {
super(client);
super(Error.class, client);
this.id = id;
this.error = error;
}
......@@ -82,8 +83,14 @@ public class DDPClientCallback {
public static class Timeout extends BaseException {
public Timeout(DDPClient client) {
super(client);
super(Timeout.class, client);
}
}
}
public static class Closed extends BaseException {
public Closed(DDPClient client) {
super(Closed.class, client);
}
}
}
......@@ -63,15 +63,15 @@ public class RxWebSocket {
}).publish();
}
public void sendText(String message) throws IOException {
webSocket.send(message);
public boolean sendText(String message) throws IOException {
return webSocket.send(message);
}
public boolean isConnected() {
return isConnected;
}
public void close(int code, String reason) throws IOException {
webSocket.close(code, reason);
public boolean close(int code, String reason) throws IOException {
return webSocket.close(code, reason);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment