当前位置: 首页>>代码示例>>Java>>正文


Java WebSocket.PayloadType方法代码示例

本文整理汇总了Java中com.squareup.okhttp.ws.WebSocket.PayloadType方法的典型用法代码示例。如果您正苦于以下问题:Java WebSocket.PayloadType方法的具体用法?Java WebSocket.PayloadType怎么用?Java WebSocket.PayloadType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.squareup.okhttp.ws.WebSocket的用法示例。


在下文中一共展示了WebSocket.PayloadType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onMessage

import com.squareup.okhttp.ws.WebSocket; //导入方法依赖的package包/类
@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();
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:35,代码来源:WXWebSocketManager.java

示例2: onMessage

import com.squareup.okhttp.ws.WebSocket; //导入方法依赖的package包/类
@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();
    }
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:13,代码来源:HotRefreshManager.java

示例3: onMessage

import com.squareup.okhttp.ws.WebSocket; //导入方法依赖的package包/类
@Override
public void onMessage(BufferedSource payload, WebSocket.PayloadType type) throws IOException {
  if (type != WebSocket.PayloadType.TEXT) {
    FLog.w(TAG, "Websocket received unexpected message with payload of type " + type);
    return;
  }

  String message = null;
  try {
    message = payload.readUtf8();
  } finally {
    payload.close();
  }
  Integer replyID = null;

  try {
    JsonParser parser = new JsonFactory().createParser(message);
    String result = null;
    while (parser.nextToken() != JsonToken.END_OBJECT) {
      String field = parser.getCurrentName();
      if ("replyID".equals(field)) {
        parser.nextToken();
        replyID = parser.getIntValue();
      } else if ("result".equals(field)) {
        parser.nextToken();
        result = parser.getText();
      }
    }
    if (replyID != null) {
      triggerRequestSuccess(replyID, result);
    }
  } catch (IOException e) {
    if (replyID != null) {
      triggerRequestFailure(replyID, e);
    } else {
      abort("Parsing response message from websocket failed", e);
    }
  }
}
 
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:40,代码来源:JSDebuggerWebSocketClient.java

示例4: onMessage

import com.squareup.okhttp.ws.WebSocket; //导入方法依赖的package包/类
@Override
public void onMessage(BufferedSource source, WebSocket.PayloadType payloadType) {
    try {
        String payload = source.readUtf8();
        JSONObject item = new JSONObject(payload);
        onMessageAll(new AxEvent(client, item));
        source.close();
    } catch (IOException e) {
        onErrorAll(e);
    }
}
 
开发者ID:Appstax,项目名称:appstax-java,代码行数:12,代码来源:AxSocket.java

示例5: onMessage

import com.squareup.okhttp.ws.WebSocket; //导入方法依赖的package包/类
@Override
public void onMessage(BufferedSource source, WebSocket.PayloadType type) throws IOException {
    String payload = source.readUtf8();

    if (payload.contains(pattern)) {
        res.set(payload);
        lock.countDown();
    }

    source.close();
}
 
开发者ID:Appstax,项目名称:appstax-java,代码行数:12,代码来源:AxChannelTest.java

示例6: onMessage

import com.squareup.okhttp.ws.WebSocket; //导入方法依赖的package包/类
@Override
public void onMessage(BufferedSource payload, WebSocket.PayloadType type)
        throws IOException {
    mProxy.handleMessage(payload, type);
}
 
开发者ID:Laisly,项目名称:weex,代码行数:6,代码来源:DebugSocketClient.java

示例7: onMessage

import com.squareup.okhttp.ws.WebSocket; //导入方法依赖的package包/类
@Override
public void onMessage(BufferedSource payload, WebSocket.PayloadType type) throws IOException {
    payload.close();
}
 
开发者ID:hosopy,项目名称:actioncable-client-java,代码行数:5,代码来源:SubscriptionsTest.java

示例8: onMessage

import com.squareup.okhttp.ws.WebSocket; //导入方法依赖的package包/类
@Override
public void onMessage(BufferedSource payload, WebSocket.PayloadType type) throws IOException {
}
 
开发者ID:hosopy,项目名称:actioncable-client-java,代码行数:4,代码来源:ConnectionTest.java


注:本文中的com.squareup.okhttp.ws.WebSocket.PayloadType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。