use of org.whispersystems.signalservice.api.push.SignalServiceAddress in project Signal-Android by WhisperSystems.
the class SignalServiceAddressProtobufSerializer method fromProtobuf.
public static SignalServiceAddress fromProtobuf(AddressProto addressProto) {
ServiceId serviceId = ServiceId.parseOrThrow(addressProto.getUuid().toByteArray());
Optional<String> number = addressProto.hasE164() ? Optional.of(addressProto.getE164()) : Optional.absent();
return new SignalServiceAddress(serviceId, number);
}
use of org.whispersystems.signalservice.api.push.SignalServiceAddress in project Signal-Android by WhisperSystems.
the class SignalServiceMessageReceiver method retrieveMessages.
public List<SignalServiceEnvelope> retrieveMessages(MessageReceivedCallback callback) throws IOException {
List<SignalServiceEnvelope> results = new LinkedList<>();
SignalServiceMessagesResult messageResult = socket.getMessages();
for (SignalServiceEnvelopeEntity entity : messageResult.getEnvelopes()) {
SignalServiceEnvelope envelope;
if (entity.hasSource() && entity.getSourceDevice() > 0) {
SignalServiceAddress address = new SignalServiceAddress(ACI.parseOrThrow(entity.getSourceUuid()), entity.getSourceE164());
envelope = new SignalServiceEnvelope(entity.getType(), Optional.of(address), entity.getSourceDevice(), entity.getTimestamp(), entity.getMessage(), entity.getContent(), entity.getServerTimestamp(), messageResult.getServerDeliveredTimestamp(), entity.getServerUuid());
} else {
envelope = new SignalServiceEnvelope(entity.getType(), entity.getTimestamp(), entity.getMessage(), entity.getContent(), entity.getServerTimestamp(), messageResult.getServerDeliveredTimestamp(), entity.getServerUuid());
}
callback.onMessage(envelope);
results.add(envelope);
if (envelope.hasServerGuid()) {
socket.acknowledgeMessage(envelope.getServerGuid());
} else {
socket.acknowledgeMessage(entity.getSourceE164(), entity.getTimestamp());
}
}
return results;
}
Aggregations