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);
}
}
Aggregations