Skip to content

Commit

Permalink
PushReceiverでErrorコマンド受診時に再接続するよう修正
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuke mihara committed Feb 19, 2018
1 parent 82becd2 commit 1576a50
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/org/montsuqi/monsiaj/client/PushReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ public void run() {

private class PusherPingTimeout extends Exception {
}

private class PusherErrorCommand extends Exception {
}

@WebSocket
public class PusherWebSocket {
Expand Down Expand Up @@ -197,7 +200,7 @@ public void onConnect(Session session) {
}

@OnWebSocketMessage
public void onMessage(String message) {
public void onMessage(String message) throws PusherErrorCommand {
logger.info("---- onMessage");
logger.info(message);
messageHandler(message);
Expand Down Expand Up @@ -246,7 +249,7 @@ public void sendPing() throws PusherPingTimeout {
}
}

private void messageHandler(String message) {
private void messageHandler(String message) throws PusherErrorCommand {
JSONObject obj = new JSONObject(message);
switch (obj.getString("command")) {
case "subscribed":
Expand All @@ -260,6 +263,8 @@ private void messageHandler(String message) {
logger.error(ex, ex);
}
break;
case "error":
throw new PusherErrorCommand();
}
}

Expand Down

0 comments on commit 1576a50

Please sign in to comment.