Search in sources :

Example 6 with NullMessage

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

the class SignalServiceMessageSender method sendMessage.

private void sendMessage(VerifiedMessage message, Optional<UnidentifiedAccessPair> unidentifiedAccess) throws IOException, UntrustedIdentityException {
    byte[] nullMessageBody = DataMessage.newBuilder().setBody(Base64.encodeBytes(Util.getRandomLengthBytes(140))).build().toByteArray();
    NullMessage nullMessage = NullMessage.newBuilder().setPadding(ByteString.copyFrom(nullMessageBody)).build();
    byte[] content = Content.newBuilder().setNullMessage(nullMessage).build().toByteArray();
    SendMessageResult result = sendMessage(message.getDestination(), getTargetUnidentifiedAccess(unidentifiedAccess), message.getTimestamp(), content, false);
    if (result.getSuccess().isNeedsSync()) {
        byte[] syncMessage = createMultiDeviceVerifiedContent(message, nullMessage.toByteArray());
        sendMessage(localAddress, Optional.<UnidentifiedAccess>absent(), message.getTimestamp(), syncMessage, false);
    }
}
Also used : NullMessage(org.whispersystems.signalservice.internal.push.SignalServiceProtos.NullMessage) SendMessageResult(org.whispersystems.signalservice.api.messages.SendMessageResult)

Aggregations

NullMessage (org.whispersystems.signalservice.internal.push.SignalServiceProtos.NullMessage)6 PlaintextContent (org.whispersystems.libsignal.protocol.PlaintextContent)4 EnvelopeContent (org.whispersystems.signalservice.api.crypto.EnvelopeContent)4 Content (org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content)4 SendMessageResult (org.whispersystems.signalservice.api.messages.SendMessageResult)3 SignalServiceAddress (org.whispersystems.signalservice.api.push.SignalServiceAddress)1 SendMessageResponse (org.whispersystems.signalservice.internal.push.SendMessageResponse)1