mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-21 19:11:22 +08:00
Extract the JSPackagerWebSocketClient into a reusable packagerconnection module
Reviewed By: cwdick Differential Revision: D4488628 fbshipit-source-id: ad07b7bfe74c6916beceb0ebcc506a57319f4ae9
This commit is contained in:
committed by
Facebook Github Bot
parent
3329969b63
commit
6f2544a16b
@@ -17,6 +17,7 @@ android_library(
|
||||
react_native_target('java/com/facebook/react/module/annotations:annotations'),
|
||||
react_native_target('java/com/facebook/react/modules/debug:debug'),
|
||||
react_native_target('java/com/facebook/react/modules/systeminfo:systeminfo'),
|
||||
react_native_target('java/com/facebook/react/packagerconnection:packagerconnection'),
|
||||
react_native_target('res:devsupport'),
|
||||
],
|
||||
visibility = [
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.facebook.react.bridge.UiThreadUtil;
|
||||
import com.facebook.react.common.ReactConstants;
|
||||
import com.facebook.react.common.network.OkHttpCallUtil;
|
||||
import com.facebook.react.modules.systeminfo.AndroidInfoHelpers;
|
||||
import com.facebook.react.packagerconnection.JSPackagerWebSocketClient;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
|
||||
@@ -53,6 +53,7 @@ import com.facebook.react.common.futures.SimpleSettableFuture;
|
||||
import com.facebook.react.devsupport.DevServerHelper.PackagerCommandListener;
|
||||
import com.facebook.react.devsupport.StackTraceHelper.StackFrame;
|
||||
import com.facebook.react.modules.debug.DeveloperSettings;
|
||||
import com.facebook.react.packagerconnection.JSPackagerWebSocketClient;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
include_defs('//ReactAndroid/DEFS')
|
||||
|
||||
android_library(
|
||||
name = 'packagerconnection',
|
||||
srcs = glob(['**/*.java']),
|
||||
deps = [
|
||||
react_native_dep('libraries/fbcore/src/main/java/com/facebook/common/logging:logging'),
|
||||
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
|
||||
react_native_dep('third-party/java/jsr-305:jsr-305'),
|
||||
react_native_dep('third-party/java/okhttp:okhttp3'),
|
||||
react_native_dep('third-party/java/okhttp:okhttp3-ws'),
|
||||
react_native_dep('third-party/java/okio:okio'),
|
||||
],
|
||||
visibility = [
|
||||
'PUBLIC',
|
||||
],
|
||||
)
|
||||
@@ -6,7 +6,7 @@
|
||||
* file in the same directory.
|
||||
*/
|
||||
|
||||
package com.facebook.react.devsupport;
|
||||
package com.facebook.react.packagerconnection;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -161,7 +161,9 @@ public class JSPackagerWebSocketClient implements WebSocketListener {
|
||||
action = reader.nextString();
|
||||
}
|
||||
}
|
||||
if (version != 1) {
|
||||
reader.close();
|
||||
|
||||
if (version == null || version != 1) {
|
||||
return;
|
||||
}
|
||||
if (target == null || action == null) {
|
||||
Reference in New Issue
Block a user