本文整理汇总了Java中com.google.protos.ipc.invalidation.ClientProtocol.ServerHeader.getServerTimeMs方法的典型用法代码示例。如果您正苦于以下问题:Java ServerHeader.getServerTimeMs方法的具体用法?Java ServerHeader.getServerTimeMs怎么用?Java ServerHeader.getServerTimeMs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.protos.ipc.invalidation.ClientProtocol.ServerHeader
的用法示例。
在下文中一共展示了ServerHeader.getServerTimeMs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getField
import com.google.protos.ipc.invalidation.ClientProtocol.ServerHeader; //导入方法依赖的package包/类
/** Returns the {@code field} from {@code message}. */
@Override
@SuppressWarnings("unchecked")
public Object getField(MessageLite rawMessage, Descriptor field) {
Preconditions.checkNotNull(rawMessage);
Preconditions.checkNotNull(field);
ServerHeader message = (ServerHeader) rawMessage;
if (field == PROTOCOL_VERSION) {
return message.getProtocolVersion();
}
if (field == CLIENT_TOKEN) {
return message.getClientToken();
}
if (field == REGISTRATION_SUMMARY) {
return message.getRegistrationSummary();
}
if (field == SERVER_TIME_MS) {
return message.getServerTimeMs();
}
if (field == MESSAGE_ID) {
return message.getMessageId();
}
throw new IllegalArgumentException("Bad descriptor: " + field);
}
示例2: postValidate
import com.google.protos.ipc.invalidation.ClientProtocol.ServerHeader; //导入方法依赖的package包/类
@Override
public boolean postValidate(MessageLite message) {
ServerHeader header = (ServerHeader) message;
if (header.getClientToken().isEmpty()) {
logger.info("Client token was empty: %s", header);
return false;
}
if (header.getServerTimeMs() < 0) {
logger.info("Server time was negative: %s", header);
return false;
}
// If set, message id must not be empty.
// Do not use String.isEmpty() here for Froyo (JDK5) compatibility.
if (header.hasMessageId() && (header.getMessageId().length() == 0)) {
logger.info("Message id was set but empty: %s", header);
return false;
}
return true;
}