本文整理汇总了Java中com.google.protos.ipc.invalidation.ClientProtocol.ServerHeader类的典型用法代码示例。如果您正苦于以下问题:Java ServerHeader类的具体用法?Java ServerHeader怎么用?Java ServerHeader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServerHeader类属于com.google.protos.ipc.invalidation.ClientProtocol包,在下文中一共展示了ServerHeader类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ParsedMessage
import com.google.protos.ipc.invalidation.ClientProtocol.ServerHeader; //导入依赖的package包/类
/** Constructs an instance from a {@code rawMessage}. */
ParsedMessage(ServerToClientMessage rawMessage) {
// For each field, assign it to the corresponding protobuf field if present, else null.
ServerHeader messageHeader = rawMessage.getHeader();
header = new ServerMessageHeader(messageHeader.getClientToken(),
messageHeader.hasRegistrationSummary() ? messageHeader.getRegistrationSummary() : null);
tokenControlMessage = rawMessage.hasTokenControlMessage() ?
rawMessage.getTokenControlMessage() : null;
invalidationMessage = rawMessage.hasInvalidationMessage() ?
rawMessage.getInvalidationMessage() : null;
registrationStatusMessage = rawMessage.hasRegistrationStatusMessage() ?
rawMessage.getRegistrationStatusMessage() : null;
registrationSyncRequestMessage = rawMessage.hasRegistrationSyncRequestMessage() ?
rawMessage.getRegistrationSyncRequestMessage() : null;
configChangeMessage = rawMessage.hasConfigChangeMessage() ?
rawMessage.getConfigChangeMessage() : null;
infoRequestMessage = rawMessage.hasInfoRequestMessage() ?
rawMessage.getInfoRequestMessage() : null;
errorMessage = rawMessage.hasErrorMessage() ? rawMessage.getErrorMessage() : null;
}
示例2: hasField
import com.google.protos.ipc.invalidation.ClientProtocol.ServerHeader; //导入依赖的package包/类
/** Returns whether {@code field} is present in {@code message}. */
@Override
@SuppressWarnings("unchecked")
public boolean hasField(MessageLite rawMessage, Descriptor field) {
Preconditions.checkNotNull(rawMessage);
Preconditions.checkNotNull(field);
ServerHeader message = (ServerHeader) rawMessage;
if (field == PROTOCOL_VERSION) {
return message.hasProtocolVersion();
}
if (field == CLIENT_TOKEN) {
return message.hasClientToken();
}
if (field == REGISTRATION_SUMMARY) {
return message.hasRegistrationSummary();
}
if (field == SERVER_TIME_MS) {
return message.hasServerTimeMs();
}
if (field == MESSAGE_ID) {
return message.hasMessageId();
}
throw new IllegalArgumentException("Bad descriptor: " + field);
}
示例3: 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);
}
示例4: 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;
}
示例5: toCompactString
import com.google.protos.ipc.invalidation.ClientProtocol.ServerHeader; //导入依赖的package包/类
public static TextBuilder toCompactString(TextBuilder builder, ServerHeader header) {
if (header == null) {
return builder;
}
builder.append("S2C: ");
toCompactString(builder, header.getProtocolVersion());
builder.appendFormat(", MsgId: %s, Num regs = %s, Token = ", header.getMessageId(),
header.getRegistrationSummary().getNumRegistrations());
toCompactString(builder, header.getClientToken());
return builder;
}
示例6: newServerHeader
import com.google.protos.ipc.invalidation.ClientProtocol.ServerHeader; //导入依赖的package包/类
public static ServerHeader newServerHeader(ByteString clientToken, long currentTimeMs,
RegistrationSummary registrationSummary, String messageId) {
ServerHeader.Builder builder = ServerHeader.newBuilder()
.setProtocolVersion(CommonInvalidationConstants2.PROTOCOL_VERSION)
.setClientToken(clientToken)
.setServerTimeMs(currentTimeMs);
if (registrationSummary != null) {
builder.setRegistrationSummary(registrationSummary);
}
if (messageId != null) {
builder.setMessageId(messageId);
}
return builder.build();
}
示例7: newServerToClientMessage
import com.google.protos.ipc.invalidation.ClientProtocol.ServerHeader; //导入依赖的package包/类
public static ServerToClientMessage newServerToClientMessage(ServerHeader scHeader,
RegistrationSyncRequestMessage syncRequestionMessage) {
return ServerToClientMessage.newBuilder()
.setHeader(scHeader)
.setRegistrationSyncRequestMessage(syncRequestionMessage)
.build();
}