mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-09 17:31:39 +08:00
Update okhttp3
Reviewed By: bestander Differential Revision: D5078004 fbshipit-source-id: 79c66cedeeb682d8bb4e67798b41115899fd1c81
This commit is contained in:
committed by
Facebook Github Bot
parent
658f632f59
commit
93a1d592d6
@@ -12,7 +12,6 @@ android_library(
|
||||
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"),
|
||||
react_native_target("java/com/facebook/react/bridge:bridge"),
|
||||
react_native_target("java/com/facebook/react/common:common"),
|
||||
|
||||
@@ -19,13 +19,9 @@ import com.facebook.react.bridge.Inspector;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
import okhttp3.ws.WebSocket;
|
||||
import okhttp3.ws.WebSocketCall;
|
||||
import okhttp3.ws.WebSocketListener;
|
||||
import okio.Buffer;
|
||||
import okhttp3.WebSocket;
|
||||
import okhttp3.WebSocketListener;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
@@ -175,7 +171,7 @@ public class InspectorPackagerConnection {
|
||||
return payload;
|
||||
}
|
||||
|
||||
private class Connection implements WebSocketListener {
|
||||
private class Connection extends WebSocketListener {
|
||||
private static final int RECONNECT_DELAY_MS = 2000;
|
||||
|
||||
private final String mUrl;
|
||||
@@ -196,9 +192,9 @@ public class InspectorPackagerConnection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(IOException e, Response response) {
|
||||
public void onFailure(WebSocket webSocket, Throwable t, Response response) {
|
||||
if (mWebSocket != null) {
|
||||
abort("Websocket exception", e);
|
||||
abort("Websocket exception", t);
|
||||
}
|
||||
if (!mClosed) {
|
||||
reconnect();
|
||||
@@ -206,22 +202,16 @@ public class InspectorPackagerConnection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(ResponseBody message) throws IOException {
|
||||
public void onMessage(WebSocket webSocket, String text) {
|
||||
try {
|
||||
handleProxyMessage(new JSONObject(message.string()));
|
||||
} catch (JSONException e) {
|
||||
throw new IOException(e);
|
||||
} finally {
|
||||
message.close();
|
||||
handleProxyMessage(new JSONObject(text));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPong(Buffer payload) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(int code, String reason) {
|
||||
public void onClosed(WebSocket webSocket, int code, String reason) {
|
||||
mWebSocket = null;
|
||||
closeAllConnections();
|
||||
if (!mClosed) {
|
||||
@@ -240,8 +230,7 @@ public class InspectorPackagerConnection {
|
||||
.build();
|
||||
|
||||
Request request = new Request.Builder().url(mUrl).build();
|
||||
WebSocketCall call = WebSocketCall.create(httpClient, request);
|
||||
call.enqueue(this);
|
||||
httpClient.newWebSocket(request, this);
|
||||
}
|
||||
|
||||
private void reconnect() {
|
||||
@@ -270,7 +259,7 @@ public class InspectorPackagerConnection {
|
||||
if (mWebSocket != null) {
|
||||
try {
|
||||
mWebSocket.close(1000, "End of session");
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
// swallow, no need to handle it here
|
||||
}
|
||||
mWebSocket = null;
|
||||
@@ -285,8 +274,8 @@ public class InspectorPackagerConnection {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
sockets[0].sendMessage(RequestBody.create(WebSocket.TEXT, object.toString()));
|
||||
} catch (IOException e) {
|
||||
sockets[0].send(object.toString());
|
||||
} catch (Exception e) {
|
||||
FLog.w(TAG, "Couldn't send event to packager", e);
|
||||
}
|
||||
return null;
|
||||
@@ -304,7 +293,7 @@ public class InspectorPackagerConnection {
|
||||
if (mWebSocket != null) {
|
||||
try {
|
||||
mWebSocket.close(1000, "End of session");
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
// swallow, no need to handle it here
|
||||
}
|
||||
mWebSocket = null;
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.common.JavascriptException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -28,18 +29,14 @@ import javax.annotation.Nullable;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
import okhttp3.ws.WebSocket;
|
||||
import okhttp3.ws.WebSocketCall;
|
||||
import okhttp3.ws.WebSocketListener;
|
||||
import okio.Buffer;
|
||||
import okhttp3.WebSocket;
|
||||
import okhttp3.WebSocketListener;
|
||||
|
||||
/**
|
||||
* A wrapper around WebSocketClient that recognizes RN debugging message format.
|
||||
*/
|
||||
public class JSDebuggerWebSocketClient implements WebSocketListener {
|
||||
public class JSDebuggerWebSocketClient extends WebSocketListener {
|
||||
|
||||
private static final String TAG = "JSDebuggerWebSocketClient";
|
||||
|
||||
@@ -67,8 +64,7 @@ public class JSDebuggerWebSocketClient implements WebSocketListener {
|
||||
.build();
|
||||
|
||||
Request request = new Request.Builder().url(url).build();
|
||||
WebSocketCall call = WebSocketCall.create(mHttpClient, request);
|
||||
call.enqueue(this);
|
||||
mHttpClient.newWebSocket(request, this);
|
||||
}
|
||||
|
||||
public void prepareJSRuntime(JSDebuggerCallback callback) {
|
||||
@@ -142,7 +138,7 @@ public class JSDebuggerWebSocketClient implements WebSocketListener {
|
||||
if (mWebSocket != null) {
|
||||
try {
|
||||
mWebSocket.close(1000, "End of session");
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
// swallow, no need to handle it here
|
||||
}
|
||||
mWebSocket = null;
|
||||
@@ -157,8 +153,8 @@ public class JSDebuggerWebSocketClient implements WebSocketListener {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, message));
|
||||
} catch (IOException e) {
|
||||
mWebSocket.send(message);
|
||||
} catch (Exception e) {
|
||||
triggerRequestFailure(requestID, e);
|
||||
}
|
||||
}
|
||||
@@ -180,16 +176,11 @@ public class JSDebuggerWebSocketClient implements WebSocketListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(ResponseBody response) throws IOException {
|
||||
if (response.contentType() != WebSocket.TEXT) {
|
||||
FLog.w(TAG, "Websocket received unexpected message with payload of type " + response.contentType());
|
||||
return;
|
||||
}
|
||||
|
||||
public void onMessage(WebSocket webSocket, String text) {
|
||||
Integer replyID = null;
|
||||
|
||||
try {
|
||||
JsonReader reader = new JsonReader(response.charStream());
|
||||
JsonReader reader = new JsonReader(new StringReader(text));
|
||||
String result = null;
|
||||
reader.beginObject();
|
||||
while (reader.hasNext()) {
|
||||
@@ -218,14 +209,12 @@ public class JSDebuggerWebSocketClient implements WebSocketListener {
|
||||
} else {
|
||||
abort("Parsing response message from websocket failed", e);
|
||||
}
|
||||
} finally {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(IOException e, Response response) {
|
||||
abort("Websocket exception", e);
|
||||
public void onFailure(WebSocket webSocket, Throwable t, Response response) {
|
||||
abort("Websocket exception", t);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -236,15 +225,10 @@ public class JSDebuggerWebSocketClient implements WebSocketListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(int code, String reason) {
|
||||
public void onClosed(WebSocket webSocket, int code, String reason) {
|
||||
mWebSocket = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPong(Buffer payload) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
private void abort(String message, Throwable cause) {
|
||||
FLog.e(TAG, "Error occurred, shutting down websocket connection: " + message, cause);
|
||||
closeQuietly();
|
||||
|
||||
@@ -11,7 +11,6 @@ android_library(
|
||||
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"),
|
||||
react_native_target("java/com/facebook/react/bridge:bridge"),
|
||||
react_native_target("java/com/facebook/react/common:common"),
|
||||
|
||||
@@ -9,11 +9,15 @@
|
||||
|
||||
package com.facebook.react.modules.websocket;
|
||||
|
||||
import android.util.Base64;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.IllegalStateException;
|
||||
import javax.annotation.Nullable;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
@@ -33,21 +37,9 @@ import com.facebook.react.modules.network.ForwardingCookieHandler;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
import okhttp3.ws.WebSocket;
|
||||
import okhttp3.ws.WebSocketCall;
|
||||
import okhttp3.ws.WebSocketListener;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URI;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import okio.Buffer;
|
||||
import okhttp3.WebSocket;
|
||||
import okhttp3.WebSocketListener;
|
||||
import okio.ByteString;
|
||||
|
||||
@ReactModule(name = "WebSocketModule", hasConstants = false)
|
||||
@@ -132,7 +124,7 @@ public class WebSocketModule extends ReactContextBaseJavaModule {
|
||||
}
|
||||
}
|
||||
|
||||
WebSocketCall.create(client, builder.build()).enqueue(new WebSocketListener() {
|
||||
client.newWebSocket(builder.build(), new WebSocketListener() {
|
||||
|
||||
@Override
|
||||
public void onOpen(WebSocket webSocket, Response response) {
|
||||
@@ -143,7 +135,7 @@ public class WebSocketModule extends ReactContextBaseJavaModule {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(int code, String reason) {
|
||||
public void onClosed(WebSocket webSocket, int code, String reason) {
|
||||
WritableMap params = Arguments.createMap();
|
||||
params.putInt("id", id);
|
||||
params.putInt("code", code);
|
||||
@@ -152,40 +144,26 @@ public class WebSocketModule extends ReactContextBaseJavaModule {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(IOException e, Response response) {
|
||||
notifyWebSocketFailed(id, e.getMessage());
|
||||
public void onFailure(WebSocket webSocket, Throwable t, Response response) {
|
||||
notifyWebSocketFailed(id, t.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPong(Buffer buffer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(ResponseBody response) throws IOException {
|
||||
String message;
|
||||
try {
|
||||
if (response.contentType() == WebSocket.BINARY) {
|
||||
message = Base64.encodeToString(response.source().readByteArray(), Base64.NO_WRAP);
|
||||
} else {
|
||||
message = response.source().readUtf8();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
notifyWebSocketFailed(id, e.getMessage());
|
||||
return;
|
||||
}
|
||||
try {
|
||||
response.source().close();
|
||||
} catch (IOException e) {
|
||||
FLog.e(
|
||||
ReactConstants.TAG,
|
||||
"Could not close BufferedSource for WebSocket id " + id,
|
||||
e);
|
||||
}
|
||||
|
||||
public void onMessage(WebSocket webSocket, String text) {
|
||||
WritableMap params = Arguments.createMap();
|
||||
params.putInt("id", id);
|
||||
params.putString("data", message);
|
||||
params.putString("type", response.contentType() == WebSocket.BINARY ? "binary" : "text");
|
||||
params.putString("data", text);
|
||||
params.putString("type", "text");
|
||||
sendEvent("websocketMessage", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(WebSocket webSocket, ByteString bytes) {
|
||||
String text = bytes.utf8();
|
||||
WritableMap params = Arguments.createMap();
|
||||
params.putInt("id", id);
|
||||
params.putString("data", text);
|
||||
params.putString("type", "binary");
|
||||
sendEvent("websocketMessage", params);
|
||||
}
|
||||
});
|
||||
@@ -221,8 +199,8 @@ public class WebSocketModule extends ReactContextBaseJavaModule {
|
||||
throw new RuntimeException("Cannot send a message. Unknown WebSocket id " + id);
|
||||
}
|
||||
try {
|
||||
client.sendMessage(RequestBody.create(WebSocket.TEXT, message));
|
||||
} catch (IOException | IllegalStateException e) {
|
||||
client.send(message);
|
||||
} catch (Exception e) {
|
||||
notifyWebSocketFailed(id, e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -235,9 +213,8 @@ public class WebSocketModule extends ReactContextBaseJavaModule {
|
||||
throw new RuntimeException("Cannot send a message. Unknown WebSocket id " + id);
|
||||
}
|
||||
try {
|
||||
client.sendMessage(
|
||||
RequestBody.create(WebSocket.BINARY, ByteString.decodeBase64(base64String)));
|
||||
} catch (IOException | IllegalStateException e) {
|
||||
client.send(ByteString.decodeBase64(base64String));
|
||||
} catch (Exception e) {
|
||||
notifyWebSocketFailed(id, e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -250,9 +227,8 @@ public class WebSocketModule extends ReactContextBaseJavaModule {
|
||||
throw new RuntimeException("Cannot send a message. Unknown WebSocket id " + id);
|
||||
}
|
||||
try {
|
||||
Buffer buffer = new Buffer();
|
||||
client.sendPing(buffer);
|
||||
} catch (IOException | IllegalStateException e) {
|
||||
client.send(ByteString.EMPTY);
|
||||
} catch (Exception e) {
|
||||
notifyWebSocketFailed(id, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ android_library(
|
||||
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"),
|
||||
react_native_target("java/com/facebook/react/modules/systeminfo:systeminfo-moduleless"),
|
||||
] + ([react_native_target("jni/packagerconnection:jni")] if not IS_OSS_BUILD else []),
|
||||
|
||||
@@ -15,9 +15,7 @@ import android.net.Uri;
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.react.modules.systeminfo.AndroidInfoHelpers;
|
||||
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.ResponseBody;
|
||||
import okhttp3.ws.WebSocket;
|
||||
import okio.ByteString;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
@@ -42,7 +40,7 @@ final public class JSPackagerClient implements ReconnectingWebSocket.MessageCall
|
||||
message.put("version", PROTOCOL_VERSION);
|
||||
message.put("id", mId);
|
||||
message.put("result", result);
|
||||
mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, message.toString()));
|
||||
mWebSocket.sendMessage(message.toString());
|
||||
} catch (Exception e) {
|
||||
FLog.e(TAG, "Responding failed", e);
|
||||
}
|
||||
@@ -54,7 +52,7 @@ final public class JSPackagerClient implements ReconnectingWebSocket.MessageCall
|
||||
message.put("version", PROTOCOL_VERSION);
|
||||
message.put("id", mId);
|
||||
message.put("error", error);
|
||||
mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, message.toString()));
|
||||
mWebSocket.sendMessage(message.toString());
|
||||
} catch (Exception e) {
|
||||
FLog.e(TAG, "Responding with error failed", e);
|
||||
}
|
||||
@@ -89,16 +87,9 @@ final public class JSPackagerClient implements ReconnectingWebSocket.MessageCall
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(ResponseBody response) {
|
||||
if (response.contentType() != WebSocket.TEXT) {
|
||||
FLog.w(
|
||||
TAG,
|
||||
"Websocket received message with payload of unexpected type " + response.contentType());
|
||||
return;
|
||||
}
|
||||
|
||||
public void onMessage(String text) {
|
||||
try {
|
||||
JSONObject message = new JSONObject(response.string());
|
||||
JSONObject message = new JSONObject(text);
|
||||
|
||||
int version = message.optInt("version");
|
||||
String method = message.optString("method");
|
||||
@@ -130,11 +121,14 @@ final public class JSPackagerClient implements ReconnectingWebSocket.MessageCall
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FLog.e(TAG, "Handling the message failed", e);
|
||||
} finally {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(ByteString bytes) {
|
||||
FLog.w(TAG, "Websocket received message with payload of unexpected type binary");
|
||||
}
|
||||
|
||||
private void abortOnMessage(Object id, String reason) {
|
||||
if (id != null) {
|
||||
(new ResponderImpl(id)).error(reason);
|
||||
|
||||
@@ -21,24 +21,22 @@ import com.facebook.common.logging.FLog;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
import okhttp3.ws.WebSocket;
|
||||
import okhttp3.ws.WebSocketCall;
|
||||
import okhttp3.ws.WebSocketListener;
|
||||
import okio.Buffer;
|
||||
import okhttp3.WebSocket;
|
||||
import okhttp3.WebSocketListener;
|
||||
import okio.ByteString;
|
||||
|
||||
/**
|
||||
* A wrapper around WebSocketClient that reconnects automatically
|
||||
*/
|
||||
final public class ReconnectingWebSocket implements WebSocketListener {
|
||||
final public class ReconnectingWebSocket extends WebSocketListener {
|
||||
private static final String TAG = ReconnectingWebSocket.class.getSimpleName();
|
||||
|
||||
private static final int RECONNECT_DELAY_MS = 2000;
|
||||
|
||||
public interface MessageCallback {
|
||||
void onMessage(ResponseBody message);
|
||||
void onMessage(String text);
|
||||
void onMessage(ByteString bytes);
|
||||
}
|
||||
|
||||
public interface ConnectionCallback {
|
||||
@@ -77,8 +75,7 @@ final public class ReconnectingWebSocket implements WebSocketListener {
|
||||
.build();
|
||||
|
||||
Request request = new Request.Builder().url(mUrl).build();
|
||||
WebSocketCall call = WebSocketCall.create(httpClient, request);
|
||||
call.enqueue(this);
|
||||
httpClient.newWebSocket(request, this);
|
||||
}
|
||||
|
||||
private synchronized void delayedReconnect() {
|
||||
@@ -122,7 +119,7 @@ final public class ReconnectingWebSocket implements WebSocketListener {
|
||||
if (mWebSocket != null) {
|
||||
try {
|
||||
mWebSocket.close(1000, "End of session");
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
// swallow, no need to handle it here
|
||||
}
|
||||
mWebSocket = null;
|
||||
@@ -145,9 +142,9 @@ final public class ReconnectingWebSocket implements WebSocketListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onFailure(IOException e, Response response) {
|
||||
public synchronized void onFailure(WebSocket webSocket, Throwable t, Response response) {
|
||||
if (mWebSocket != null) {
|
||||
abort("Websocket exception", e);
|
||||
abort("Websocket exception", t);
|
||||
}
|
||||
if (!mClosed) {
|
||||
if (mConnectionCallback != null) {
|
||||
@@ -158,17 +155,21 @@ final public class ReconnectingWebSocket implements WebSocketListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onMessage(ResponseBody message) {
|
||||
public synchronized void onMessage(WebSocket webSocket, String text) {
|
||||
if (mMessageCallback != null) {
|
||||
mMessageCallback.onMessage(message);
|
||||
mMessageCallback.onMessage(text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onPong(Buffer payload) { }
|
||||
public synchronized void onMessage(WebSocket webSocket, ByteString bytes) {
|
||||
if (mMessageCallback != null) {
|
||||
mMessageCallback.onMessage(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onClose(int code, String reason) {
|
||||
public synchronized void onClosed(WebSocket webSocket, int code, String reason) {
|
||||
mWebSocket = null;
|
||||
if (!mClosed) {
|
||||
if (mConnectionCallback != null) {
|
||||
@@ -178,9 +179,17 @@ final public class ReconnectingWebSocket implements WebSocketListener {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void sendMessage(RequestBody message) throws IOException {
|
||||
public synchronized void sendMessage(String message) throws IOException {
|
||||
if (mWebSocket != null) {
|
||||
mWebSocket.sendMessage(message);
|
||||
mWebSocket.send(message);
|
||||
} else {
|
||||
throw new ClosedChannelException();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void sendMessage(ByteString message) throws IOException {
|
||||
if (mWebSocket != null) {
|
||||
mWebSocket.send(message);
|
||||
} else {
|
||||
throw new ClosedChannelException();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user