本文整理汇总了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();
}
}
示例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();
}
}
}
示例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);
}
}
}
示例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);
}
}
示例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();
}
示例6: onMessage
import com.squareup.okhttp.ws.WebSocket; //导入方法依赖的package包/类
@Override
public void onMessage(BufferedSource payload, WebSocket.PayloadType type)
throws IOException {
mProxy.handleMessage(payload, type);
}
示例7: onMessage
import com.squareup.okhttp.ws.WebSocket; //导入方法依赖的package包/类
@Override
public void onMessage(BufferedSource payload, WebSocket.PayloadType type) throws IOException {
payload.close();
}
示例8: onMessage
import com.squareup.okhttp.ws.WebSocket; //导入方法依赖的package包/类
@Override
public void onMessage(BufferedSource payload, WebSocket.PayloadType type) throws IOException {
}