Java Code Examples for com.squareup.okhttp.ws.WebSocket#PayloadType

The following examples show how to use com.squareup.okhttp.ws.WebSocket#PayloadType . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HotRefreshManager.java    From incubator-weex-playground with Apache License 2.0 5 votes vote down vote up
@Override
public void onMessage(BufferedSource payload, WebSocket.PayloadType type) throws IOException {
  if (type == WebSocket.PayloadType.TEXT) {
    String temp = payload.readUtf8();
    Log.e(TAG, "into--[onMessage] msg:" + temp);
    payload.close();

    if (TextUtils.equals("refresh", temp) && mHandler != null) {
      mHandler.obtainMessage(Constants.HOT_REFRESH_REFRESH, 0, 0, mUrl).sendToTarget();
    }
  }
}
 
Example 2
Source File: HotRefreshManager.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
@Override
public void onMessage(BufferedSource payload, WebSocket.PayloadType type) throws IOException {
  if (type == WebSocket.PayloadType.TEXT) {
    String temp = payload.readUtf8();
    Log.e(TAG, "into--[onMessage] msg:" + temp);
    payload.close();

    if (TextUtils.equals("refresh", temp) && mHandler != null) {
      mHandler.obtainMessage(Constants.HOT_REFRESH_REFRESH, 0, 0, mUrl).sendToTarget();
    }
  }
}
 
Example 3
Source File: WXWebSocketManager.java    From weex with Apache License 2.0 5 votes vote down vote up
@Override
public void onMessage(BufferedSource payload, WebSocket.PayloadType type)
    throws IOException {
  if (type != WebSocket.PayloadType.TEXT) {
    WXLogUtils.w(
        "Websocket received unexpected message with payload of type "
        + type);
    return;
  }
  for (JSDebuggerCallback callback : mCallbacks.values()) {
    callback.onMessage(payload, type);
  }

  String message = null;
  try {
    message = payload.readUtf8();
    JSONObject jsonObject = JSONObject.parseObject(message);
    Object name = jsonObject.get("method");
    Object value = jsonObject.get("arguments");
    if (name == null || value == null) {
      return;
    }
    if (TextUtils.equals(name.toString(), "setLogLevel")) {
      JSONArray jsonArray = JSONObject.parseArray(value.toString());
      String level = jsonArray.get(0).toString();
      WXEnvironment.sLogLevel = LogLevel.valueOf(level.toUpperCase());
      WXLogUtils.v("into--[onMessage]setLogLevel");
    }
  } catch (Exception e) {

  } finally {
    payload.close();
  }
}
 
Example 4
Source File: HotRefreshManager.java    From weex with Apache License 2.0 5 votes vote down vote up
@Override
public void onMessage(BufferedSource payload, WebSocket.PayloadType type) throws IOException {
  if (type == WebSocket.PayloadType.TEXT) {
    String temp = payload.readUtf8();
    Log.e(TAG, "into--[onMessage] msg:" + temp);
    payload.close();

    if (TextUtils.equals("refresh", temp) && mHandler != null) {
      mHandler.obtainMessage(Constants.HOT_REFRESH_REFRESH, 0, 0, mUrl).sendToTarget();
    }
  }
}
 
Example 5
Source File: DebugSocketClient.java    From weex with Apache License 2.0 4 votes vote down vote up
@Override
public void onMessage(BufferedSource payload, WebSocket.PayloadType type)
        throws IOException {
    mProxy.handleMessage(payload, type);
}
 
Example 6
Source File: SubscriptionsTest.java    From actioncable-client-java with MIT License 4 votes vote down vote up
@Override
public void onMessage(BufferedSource payload, WebSocket.PayloadType type) throws IOException {
    payload.close();
}
 
Example 7
Source File: ConnectionTest.java    From actioncable-client-java with MIT License 4 votes vote down vote up
@Override
public void onMessage(BufferedSource payload, WebSocket.PayloadType type) throws IOException {
}
 
Example 8
Source File: ConsumerTest.java    From actioncable-client-java with MIT License 4 votes vote down vote up
@Override
public void onMessage(BufferedSource payload, WebSocket.PayloadType type) throws IOException {
    payload.close();
}
 
Example 9
Source File: SubscriptionTest.java    From actioncable-client-java with MIT License 4 votes vote down vote up
@Override
public void onMessage(BufferedSource payload, WebSocket.PayloadType type) throws IOException {
    payload.close();
}
 
Example 10
Source File: WXWebSocketManager.java    From weex with Apache License 2.0 votes vote down vote up
void onMessage(BufferedSource payload, WebSocket.PayloadType type);