use of org.whispersystems.signalservice.internal.push.SignalServiceMessagesResult in project Signal-Android by signalapp.
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;
}
use of org.whispersystems.signalservice.internal.push.SignalServiceMessagesResult 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