本文整理汇总了Java中com.google.protos.ipc.invalidation.AndroidService.AndroidNetworkSendRequest.parseFrom方法的典型用法代码示例。如果您正苦于以下问题:Java AndroidNetworkSendRequest.parseFrom方法的具体用法?Java AndroidNetworkSendRequest.parseFrom怎么用?Java AndroidNetworkSendRequest.parseFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.protos.ipc.invalidation.AndroidService.AndroidNetworkSendRequest
的用法示例。
在下文中一共展示了AndroidNetworkSendRequest.parseFrom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleOutboundMessage
import com.google.protos.ipc.invalidation.AndroidService.AndroidNetworkSendRequest; //导入方法依赖的package包/类
/**
* Handles a request to send a message to the data center. Validates the message and sends
* an intent to the application to obtain an auth token to use on the HTTP request to the
* data center.
*/
private void handleOutboundMessage(byte[] sendRequestBytes) {
// Parse and validate the send request.
final AndroidNetworkSendRequest sendRequest;
try {
sendRequest = AndroidNetworkSendRequest.parseFrom(sendRequestBytes);
} catch (InvalidProtocolBufferException exception) {
logger.warning("Failed parsing AndroidNetworkSendRequest from %s: %s",
sendRequestBytes, exception);
return;
}
if (!validator.isNetworkSendRequestValid(sendRequest)) {
logger.warning("Ignoring invalid send request: %s", sendRequest);
return;
}
// Request an auth token from the application to use when sending the message.
byte[] message = sendRequest.getMessage().toByteArray();
requestAuthTokenForMessage(message, null);
}
示例2: tryParseExtra
import com.google.protos.ipc.invalidation.AndroidService.AndroidNetworkSendRequest; //导入方法依赖的package包/类
/** Appends a description of any known extra or appends 'UNKNOWN' if none are recognized. */
private static boolean tryParseExtra(TextBuilder builder, Intent intent)
throws InvalidProtocolBufferException {
byte[] data;
data = intent.getByteArrayExtra(ProtocolIntents.SCHEDULER_KEY);
if (data != null) {
AndroidSchedulerEvent schedulerEvent = AndroidSchedulerEvent.parseFrom(data);
toCompactString(builder, schedulerEvent);
return true;
}
data = intent.getByteArrayExtra(ProtocolIntents.OUTBOUND_MESSAGE_KEY);
if (data != null) {
AndroidNetworkSendRequest outboundMessage = AndroidNetworkSendRequest.parseFrom(data);
toCompactString(builder, outboundMessage);
return true;
}
data = intent.getByteArrayExtra(ProtocolIntents.LISTENER_UPCALL_KEY);
if (data != null) {
ListenerUpcall upcall = ListenerUpcall.parseFrom(data);
toCompactString(builder, upcall);
return true;
}
data = intent.getByteArrayExtra(ProtocolIntents.INTERNAL_DOWNCALL_KEY);
if (data != null) {
InternalDowncall internalDowncall = InternalDowncall.parseFrom(data);
toCompactString(builder, internalDowncall);
return true;
}
data = intent.getByteArrayExtra(ProtocolIntents.CLIENT_DOWNCALL_KEY);
if (data != null) {
ClientDowncall clientDowncall = ClientDowncall.parseFrom(data);
toCompactString(builder, clientDowncall);
return true;
}
// Didn't recognize any intents.
return false;
}