mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-04 22:56:32 +08:00
Force the debugger to disconnect before a bundle reload
Reviewed By: bnham Differential Revision: D5594238 fbshipit-source-id: feff9f179534c8e617f8fa7c8a7b1bc525c07cae
This commit is contained in:
committed by
Facebook Github Bot
parent
f11f00197d
commit
41504103ce
@@ -90,6 +90,8 @@ public class DevServerHelper {
|
||||
private static final int LONG_POLL_FAILURE_DELAY_MS = 5000;
|
||||
private static final int HTTP_CONNECT_TIMEOUT_MS = 5000;
|
||||
|
||||
private static final String DEBUGGER_MSG_DISABLE = "{ \"id\":1,\"method\":\"Debugger.disable\" }";
|
||||
|
||||
public interface OnServerContentChangeListener {
|
||||
void onServerContentChanged();
|
||||
}
|
||||
@@ -211,6 +213,18 @@ public class DevServerHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public void sendEventToAllConnections(String event) {
|
||||
if (mInspectorPackagerConnection != null) {
|
||||
mInspectorPackagerConnection.sendEventToAllConnections(event);
|
||||
}
|
||||
}
|
||||
|
||||
public void disableDebugger() {
|
||||
if (mInspectorPackagerConnection != null) {
|
||||
mInspectorPackagerConnection.sendEventToAllConnections(DEBUGGER_MSG_DISABLE);
|
||||
}
|
||||
}
|
||||
|
||||
public void closeInspectorConnection() {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
|
||||
@@ -679,6 +679,8 @@ public class DevSupportManagerImpl implements
|
||||
|
||||
@Override
|
||||
public void onPackagerReloadCommand() {
|
||||
// Disable debugger to resume the JsVM & avoid thread locks while reloading
|
||||
mDevServerHelper.disableDebugger();
|
||||
UiThreadUtil.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
@@ -47,6 +48,14 @@ public class InspectorPackagerConnection {
|
||||
mConnection.close();
|
||||
}
|
||||
|
||||
public void sendEventToAllConnections(String event) {
|
||||
for (Map.Entry<String, Inspector.LocalConnection> inspectorConnectionEntry :
|
||||
mInspectorConnections.entrySet()) {
|
||||
Inspector.LocalConnection inspectorConnection = inspectorConnectionEntry.getValue();
|
||||
inspectorConnection.sendMessage(event);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendOpenEvent(String pageId) {
|
||||
try {
|
||||
JSONObject payload = makePageIdPayload(pageId);
|
||||
|
||||
Reference in New Issue
Block a user