本文整理汇总了Java中com.google.ipc.invalidation.ticl.ProtocolHandler.ParsedMessage类的典型用法代码示例。如果您正苦于以下问题:Java ParsedMessage类的具体用法?Java ParsedMessage怎么用?Java ParsedMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParsedMessage类属于com.google.ipc.invalidation.ticl.ProtocolHandler包,在下文中一共展示了ParsedMessage类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: validateToken
import com.google.ipc.invalidation.ticl.ProtocolHandler.ParsedMessage; //导入依赖的package包/类
/**
* Returns whether the token in the header of {@code parsedMessage} matches either the
* client token or nonce of this Ticl (depending on which is non-{@code null}).
*/
private boolean validateToken(ParsedMessage parsedMessage) {
if (clientToken != null) {
// Client token case.
if (!TypedUtil.<Bytes>equals(clientToken, parsedMessage.header.token)) {
logger.info("Incoming message has bad token: server = %s, client = %s",
parsedMessage.header.token, clientToken);
statistics.recordError(ClientErrorType.TOKEN_MISMATCH);
return false;
}
return true;
} else if (nonce != null) {
// Nonce case.
if (!TypedUtil.<Bytes>equals(nonce, parsedMessage.header.token)) {
statistics.recordError(ClientErrorType.NONCE_MISMATCH);
logger.info("Rejecting server message with mismatched nonce: Client = %s, Server = %s",
nonce, parsedMessage.header.token);
return false;
} else {
logger.info("Accepting server message with matching nonce: %s", nonce);
return true;
}
}
// Neither token nor nonce; ignore message.
logger.warning("Neither token nor nonce was set in validateToken: %s, %s", clientToken, nonce);
return false;
}
开发者ID:mogoweb,项目名称:365browser,代码行数:31,代码来源:InvalidationClientCore.java
示例2: validateToken
import com.google.ipc.invalidation.ticl.ProtocolHandler.ParsedMessage; //导入依赖的package包/类
/**
* Returns whether the token in the header of {@code parsedMessage} matches either the
* client token or nonce of this Ticl (depending on which is non-{@code null}).
*/
private boolean validateToken(ParsedMessage parsedMessage) {
if (clientToken != null) {
// Client token case.
if (!TypedUtil.<ByteString>equals(clientToken, parsedMessage.header.token)) {
logger.info("Incoming message has bad token: server = %s, client = %s",
CommonProtoStrings2.toLazyCompactString(parsedMessage.header.token),
CommonProtoStrings2.toLazyCompactString(clientToken));
statistics.recordError(ClientErrorType.TOKEN_MISMATCH);
return false;
}
return true;
} else if (nonce != null) {
// Nonce case.
if (!TypedUtil.<ByteString>equals(nonce, parsedMessage.header.token)) {
statistics.recordError(ClientErrorType.NONCE_MISMATCH);
logger.info("Rejecting server message with mismatched nonce: Client = %s, Server = %s",
CommonProtoStrings2.toLazyCompactString(nonce),
CommonProtoStrings2.toLazyCompactString(parsedMessage.header.token));
return false;
} else {
logger.info("Accepting server message with matching nonce: %s",
CommonProtoStrings2.toLazyCompactString(nonce));
return true;
}
}
// Neither token nor nonce; ignore message.
logger.warning("Neither token nor nonce was set in validateToken: %s, %s", clientToken, nonce);
return false;
}
开发者ID:morristech,项目名称:android-chromium,代码行数:34,代码来源:InvalidationClientCore.java
示例3: handleIncomingMessage
import com.google.ipc.invalidation.ticl.ProtocolHandler.ParsedMessage; //导入依赖的package包/类
/**
* Handles an {@code incomingMessage} from the data center. If it is valid and addressed to
* this client, dispatches to methods to handle sub-parts of the message; if not, drops the
* message.
*/
void handleIncomingMessage(byte[] incomingMessage) {
Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
statistics.recordReceivedMessage(ReceivedMessageType.TOTAL);
ParsedMessage parsedMessage = protocolHandler.handleIncomingMessage(incomingMessage);
if (parsedMessage == null) {
// Invalid message.
return;
}
// Ensure we have either a matching token or a matching nonce.
if (!validateToken(parsedMessage)) {
return;
}
// Handle a token-control message, if present.
if (parsedMessage.tokenControlMessage != null) {
statistics.recordReceivedMessage(ReceivedMessageType.TOKEN_CONTROL);
handleTokenChanged(parsedMessage.header.token,
parsedMessage.tokenControlMessage.hasNewToken() ?
parsedMessage.tokenControlMessage.getNewToken() : null);
}
// We might have lost our token or failed to acquire one. Ensure that we do not proceed in
// either case.
if (clientToken == null) {
return;
}
// First, handle the message header.
handleIncomingHeader(parsedMessage.header);
// Then, handle any work remaining in the message.
if (parsedMessage.invalidationMessage != null) {
statistics.recordReceivedMessage(ReceivedMessageType.INVALIDATION);
handleInvalidations(parsedMessage.invalidationMessage.getInvalidation());
}
if (parsedMessage.registrationStatusMessage != null) {
statistics.recordReceivedMessage(ReceivedMessageType.REGISTRATION_STATUS);
handleRegistrationStatus(parsedMessage.registrationStatusMessage.getRegistrationStatus());
}
if (parsedMessage.registrationSyncRequestMessage != null) {
statistics.recordReceivedMessage(ReceivedMessageType.REGISTRATION_SYNC_REQUEST);
handleRegistrationSyncRequest();
}
if (parsedMessage.infoRequestMessage != null) {
statistics.recordReceivedMessage(ReceivedMessageType.INFO_REQUEST);
handleInfoMessage(parsedMessage.infoRequestMessage.getInfoType());
}
if (parsedMessage.errorMessage != null) {
statistics.recordReceivedMessage(ReceivedMessageType.ERROR);
handleErrorMessage(parsedMessage.header, parsedMessage.errorMessage.getCode(),
parsedMessage.errorMessage.getDescription());
}
}
开发者ID:mogoweb,项目名称:365browser,代码行数:60,代码来源:InvalidationClientCore.java
示例4: handleIncomingMessage
import com.google.ipc.invalidation.ticl.ProtocolHandler.ParsedMessage; //导入依赖的package包/类
/**
* Handles an {@code incomingMessage} from the data center. If it is valid and addressed to
* this client, dispatches to methods to handle sub-parts of the message; if not, drops the
* message.
*/
void handleIncomingMessage(byte[] incomingMessage) {
Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
statistics.recordReceivedMessage(ReceivedMessageType.TOTAL);
ParsedMessage parsedMessage = protocolHandler.handleIncomingMessage(incomingMessage);
if (parsedMessage == null) {
// Invalid message.
return;
}
// Ensure we have either a matching token or a matching nonce.
if (!validateToken(parsedMessage)) {
return;
}
// Handle a token-control message, if present.
if (parsedMessage.tokenControlMessage != null) {
statistics.recordReceivedMessage(ReceivedMessageType.TOKEN_CONTROL);
handleTokenChanged(parsedMessage.header.token,
parsedMessage.tokenControlMessage.hasNewToken() ?
parsedMessage.tokenControlMessage.getNewToken() : null);
}
// We might have lost our token or failed to acquire one. Ensure that we do not proceed in
// either case.
if (clientToken == null) {
return;
}
// First, handle the message header.
handleIncomingHeader(parsedMessage.header);
// Then, handle any work remaining in the message.
if (parsedMessage.invalidationMessage != null) {
statistics.recordReceivedMessage(ReceivedMessageType.INVALIDATION);
handleInvalidations(parsedMessage.invalidationMessage.getInvalidationList());
}
if (parsedMessage.registrationStatusMessage != null) {
statistics.recordReceivedMessage(ReceivedMessageType.REGISTRATION_STATUS);
handleRegistrationStatus(parsedMessage.registrationStatusMessage.getRegistrationStatusList());
}
if (parsedMessage.registrationSyncRequestMessage != null) {
statistics.recordReceivedMessage(ReceivedMessageType.REGISTRATION_SYNC_REQUEST);
handleRegistrationSyncRequest();
}
if (parsedMessage.infoRequestMessage != null) {
statistics.recordReceivedMessage(ReceivedMessageType.INFO_REQUEST);
handleInfoMessage(parsedMessage.infoRequestMessage.getInfoTypeList());
}
if (parsedMessage.errorMessage != null) {
statistics.recordReceivedMessage(ReceivedMessageType.ERROR);
handleErrorMessage(parsedMessage.header, parsedMessage.errorMessage.getCode(),
parsedMessage.errorMessage.getDescription());
}
}
开发者ID:morristech,项目名称:android-chromium,代码行数:60,代码来源:InvalidationClientCore.java
注:本文中的com.google.ipc.invalidation.ticl.ProtocolHandler.ParsedMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论