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 { ...@@ -15,7 +15,8 @@ public class DDPClientCallback {
public static abstract class BaseException extends Exception { public static abstract class BaseException extends Exception {
public DDPClient client; public DDPClient client;
public BaseException(DDPClient client) { public BaseException(Class<? extends BaseException> clazz, DDPClient client) {
super(clazz.getName());
this.client = client; this.client = client;
} }
} }
...@@ -32,14 +33,14 @@ public class DDPClientCallback { ...@@ -32,14 +33,14 @@ public class DDPClientCallback {
public String version; public String version;
public Failed(DDPClient client, String version) { public Failed(DDPClient client, String version) {
super(client); super(Failed.class, client);
this.version = version; this.version = version;
} }
} }
public static class Timeout extends BaseException { public static class Timeout extends BaseException {
public Timeout(DDPClient client) { public Timeout(DDPClient client) {
super(client); super(Timeout.class, client);
} }
} }
} }
...@@ -54,7 +55,7 @@ public class DDPClientCallback { ...@@ -54,7 +55,7 @@ public class DDPClientCallback {
public static class Timeout extends BaseException { public static class Timeout extends BaseException {
public Timeout(DDPClient client) { public Timeout(DDPClient client) {
super(client); super(Timeout.class, client);
} }
} }
} }
...@@ -74,7 +75,7 @@ public class DDPClientCallback { ...@@ -74,7 +75,7 @@ public class DDPClientCallback {
public JSONObject error; public JSONObject error;
public Error(DDPClient client, String id, JSONObject error) { public Error(DDPClient client, String id, JSONObject error) {
super(client); super(Error.class, client);
this.id = id; this.id = id;
this.error = error; this.error = error;
} }
...@@ -82,8 +83,14 @@ public class DDPClientCallback { ...@@ -82,8 +83,14 @@ public class DDPClientCallback {
public static class Timeout extends BaseException { public static class Timeout extends BaseException {
public Timeout(DDPClient client) { 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 { ...@@ -63,15 +63,15 @@ public class RxWebSocket {
}).publish(); }).publish();
} }
public void sendText(String message) throws IOException { public boolean sendText(String message) throws IOException {
webSocket.send(message); return webSocket.send(message);
} }
public boolean isConnected() { public boolean isConnected() {
return isConnected; return isConnected;
} }
public void close(int code, String reason) throws IOException { public boolean close(int code, String reason) throws IOException {
webSocket.close(code, reason); 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