Search in sources :

Example 1 with SignalServiceEnvelopeEntity

use of org.whispersystems.signalservice.internal.push.SignalServiceEnvelopeEntity in project libsignal-service-java by signalapp.

the class SignalServiceMessageReceiver method retrieveMessages.

public List<SignalServiceEnvelope> retrieveMessages(MessageReceivedCallback callback) throws IOException {
    List<SignalServiceEnvelope> results = new LinkedList<>();
    List<SignalServiceEnvelopeEntity> entities = socket.getMessages();
    for (SignalServiceEnvelopeEntity entity : entities) {
        SignalServiceEnvelope envelope;
        if (entity.hasSource() && entity.getSourceDevice() > 0) {
            SignalServiceAddress address = new SignalServiceAddress(UuidUtil.parseOrNull(entity.getSourceUuid()), entity.getSourceE164());
            envelope = new SignalServiceEnvelope(entity.getType(), Optional.of(address), entity.getSourceDevice(), entity.getTimestamp(), entity.getMessage(), entity.getContent(), entity.getServerTimestamp(), entity.getServerUuid());
        } else {
            envelope = new SignalServiceEnvelope(entity.getType(), entity.getTimestamp(), entity.getMessage(), entity.getContent(), entity.getServerTimestamp(), entity.getServerUuid());
        }
        callback.onMessage(envelope);
        results.add(envelope);
        if (envelope.hasUuid())
            socket.acknowledgeMessage(envelope.getUuid());
        else
            socket.acknowledgeMessage(entity.getSourceE164(), entity.getTimestamp());
    }
    return results;
}
Also used : SignalServiceEnvelopeEntity(org.whispersystems.signalservice.internal.push.SignalServiceEnvelopeEntity) SignalServiceEnvelope(org.whispersystems.signalservice.api.messages.SignalServiceEnvelope) SignalServiceAddress(org.whispersystems.signalservice.api.push.SignalServiceAddress) LinkedList(java.util.LinkedList)

Example 2 with SignalServiceEnvelopeEntity

use of org.whispersystems.signalservice.internal.push.SignalServiceEnvelopeEntity 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 3 with SignalServiceEnvelopeEntity

use of org.whispersystems.signalservice.internal.push.SignalServiceEnvelopeEntity 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)3 SignalServiceEnvelope (org.whispersystems.signalservice.api.messages.SignalServiceEnvelope)3 SignalServiceAddress (org.whispersystems.signalservice.api.push.SignalServiceAddress)3 SignalServiceEnvelopeEntity (org.whispersystems.signalservice.internal.push.SignalServiceEnvelopeEntity)3 SignalServiceMessagesResult (org.whispersystems.signalservice.internal.push.SignalServiceMessagesResult)2