Search in sources :

Example 1 with SignalServiceMessagesResult

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;
}
Also used : SignalServiceEnvelopeEntity(org.whispersystems.signalservice.internal.push.SignalServiceEnvelopeEntity) SignalServiceMessagesResult(org.whispersystems.signalservice.internal.push.SignalServiceMessagesResult) SignalServiceEnvelope(org.whispersystems.signalservice.api.messages.SignalServiceEnvelope) SignalServiceAddress(org.whispersystems.signalservice.api.push.SignalServiceAddress) LinkedList(java.util.LinkedList)

Example 2 with SignalServiceMessagesResult

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;
}
Also used : SignalServiceEnvelopeEntity(org.whispersystems.signalservice.internal.push.SignalServiceEnvelopeEntity) SignalServiceMessagesResult(org.whispersystems.signalservice.internal.push.SignalServiceMessagesResult) SignalServiceEnvelope(org.whispersystems.signalservice.api.messages.SignalServiceEnvelope) SignalServiceAddress(org.whispersystems.signalservice.api.push.SignalServiceAddress) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)2 SignalServiceEnvelope (org.whispersystems.signalservice.api.messages.SignalServiceEnvelope)2 SignalServiceAddress (org.whispersystems.signalservice.api.push.SignalServiceAddress)2 SignalServiceEnvelopeEntity (org.whispersystems.signalservice.internal.push.SignalServiceEnvelopeEntity)2 SignalServiceMessagesResult (org.whispersystems.signalservice.internal.push.SignalServiceMessagesResult)2