use of org.whispersystems.signalservice.internal.push.SendMessageResponseList in project libsignal-service-java by signalapp.
the class SignalServiceMessageSender method sendMessage.
/**
* Send a message to a group.
*
* @param recipients The group members.
* @param message The group message.
* @throws IOException
* @throws EncapsulatedExceptions
*/
public void sendMessage(List<SignalServiceAddress> recipients, SignalServiceDataMessage message) throws IOException, EncapsulatedExceptions {
byte[] content = createMessageContent(message);
long timestamp = message.getTimestamp();
SendMessageResponseList response = sendMessage(recipients, timestamp, content);
try {
if (response.getNeedsSync()) {
byte[] syncMessage = createMultiDeviceSentTranscriptContent(content, Optional.<SignalServiceAddress>absent(), timestamp);
sendMessage(localAddress, timestamp, syncMessage, false);
}
} catch (UntrustedIdentityException e) {
response.addException(e);
}
if (response.hasExceptions()) {
throw new EncapsulatedExceptions(response.getUntrustedIdentities(), response.getUnregisteredUsers(), response.getNetworkExceptions());
}
}
use of org.whispersystems.signalservice.internal.push.SendMessageResponseList in project libsignal-service-java by signalapp.
the class SignalServiceMessageSender method sendMessage.
private SendMessageResponseList sendMessage(List<SignalServiceAddress> recipients, long timestamp, byte[] content) throws IOException {
SendMessageResponseList responseList = new SendMessageResponseList();
for (SignalServiceAddress recipient : recipients) {
try {
SendMessageResponse response = sendMessage(recipient, timestamp, content, false);
responseList.addResponse(response);
} catch (UntrustedIdentityException e) {
Log.w(TAG, e);
responseList.addException(e);
} catch (UnregisteredUserException e) {
Log.w(TAG, e);
responseList.addException(e);
} catch (PushNetworkException e) {
Log.w(TAG, e);
responseList.addException(new NetworkFailureException(recipient.getNumber(), e));
}
}
return responseList;
}
Aggregations