diff --git a/Android/doric/src/main/java/pub/doric/dev/DevPanel.java b/Android/doric/src/main/java/pub/doric/dev/DevPanel.java index 416de906..563e1b22 100644 --- a/Android/doric/src/main/java/pub/doric/dev/DevPanel.java +++ b/Android/doric/src/main/java/pub/doric/dev/DevPanel.java @@ -7,6 +7,7 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -28,7 +29,8 @@ import pub.doric.Doric; import pub.doric.DoricContext; import pub.doric.DoricContextManager; import pub.doric.R; -import pub.doric.dev.event.EOFEvent; +import pub.doric.dev.event.ConnectExceptionEvent; +import pub.doric.dev.event.EOFExceptionEvent; import pub.doric.dev.event.OpenEvent; public class DevPanel extends BottomSheetDialogFragment { @@ -113,11 +115,19 @@ public class DevPanel extends BottomSheetDialogFragment { @Subscribe(threadMode = ThreadMode.MAIN) public void onOpenEvent(OpenEvent openEvent) { updateUI(); + Toast.makeText(getContext(), "dev kit connected", Toast.LENGTH_LONG).show(); } @Subscribe(threadMode = ThreadMode.MAIN) - public void onEOFEvent(EOFEvent eofEvent) { + public void onEOFEvent(EOFExceptionEvent eofExceptionEvent) { updateUI(); + Toast.makeText(getContext(), "dev kit eof exception", Toast.LENGTH_LONG).show(); + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onConnectExceptionEvent(ConnectExceptionEvent connectExceptionEvent) { + updateUI(); + Toast.makeText(getContext(), "dev kit connection exception", Toast.LENGTH_LONG).show(); } private void updateUI() { diff --git a/Android/doric/src/main/java/pub/doric/dev/WSClient.java b/Android/doric/src/main/java/pub/doric/dev/WSClient.java index 9b2d4143..cf05d8ed 100644 --- a/Android/doric/src/main/java/pub/doric/dev/WSClient.java +++ b/Android/doric/src/main/java/pub/doric/dev/WSClient.java @@ -20,6 +20,7 @@ import org.json.JSONException; import org.json.JSONObject; import java.io.EOFException; +import java.net.ConnectException; import java.util.concurrent.TimeUnit; import okhttp3.OkHttpClient; @@ -29,7 +30,8 @@ import okhttp3.WebSocket; import okhttp3.WebSocketListener; import pub.doric.DoricContext; import pub.doric.DoricContextManager; -import pub.doric.dev.event.EOFEvent; +import pub.doric.dev.event.ConnectExceptionEvent; +import pub.doric.dev.event.EOFExceptionEvent; import pub.doric.dev.event.EnterDebugEvent; import pub.doric.dev.event.OpenEvent; @@ -108,7 +110,10 @@ public class WSClient extends WebSocketListener { if (t instanceof EOFException) { DevPanel.isDevConnected = false; - EventBus.getDefault().post(new EOFEvent()); + EventBus.getDefault().post(new EOFExceptionEvent()); + } else if (t instanceof ConnectException) { + DevPanel.isDevConnected = false; + EventBus.getDefault().post(new ConnectExceptionEvent()); } } diff --git a/Android/doric/src/main/java/pub/doric/dev/event/ConnectExceptionEvent.java b/Android/doric/src/main/java/pub/doric/dev/event/ConnectExceptionEvent.java new file mode 100644 index 00000000..945276ad --- /dev/null +++ b/Android/doric/src/main/java/pub/doric/dev/event/ConnectExceptionEvent.java @@ -0,0 +1,4 @@ +package pub.doric.dev.event; + +public class ConnectExceptionEvent { +} diff --git a/Android/doric/src/main/java/pub/doric/dev/event/EOFEvent.java b/Android/doric/src/main/java/pub/doric/dev/event/EOFEvent.java deleted file mode 100644 index aabb4931..00000000 --- a/Android/doric/src/main/java/pub/doric/dev/event/EOFEvent.java +++ /dev/null @@ -1,4 +0,0 @@ -package pub.doric.dev.event; - -public class EOFEvent { -} diff --git a/Android/doric/src/main/java/pub/doric/dev/event/EOFExceptionEvent.java b/Android/doric/src/main/java/pub/doric/dev/event/EOFExceptionEvent.java new file mode 100644 index 00000000..376f0e62 --- /dev/null +++ b/Android/doric/src/main/java/pub/doric/dev/event/EOFExceptionEvent.java @@ -0,0 +1,4 @@ +package pub.doric.dev.event; + +public class EOFExceptionEvent { +}