Java Code Examples for org.whispersystems.signalservice.api.messages.SignalServiceDataMessage#isEndSession()
The following examples show how to use
org.whispersystems.signalservice.api.messages.SignalServiceDataMessage#isEndSession() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
/** * Send a message to a single recipient. * * @param recipient The message's destination. * @param message The message. * @throws UntrustedIdentityException * @throws IOException */ public SendMessageResult sendMessage(SignalServiceAddress recipient, Optional<UnidentifiedAccessPair> unidentifiedAccess, SignalServiceDataMessage message) throws UntrustedIdentityException, IOException { byte[] content = createMessageContent(message); long timestamp = message.getTimestamp(); SendMessageResult result = sendMessage(recipient, getTargetUnidentifiedAccess(unidentifiedAccess), timestamp, content, false); if (result.getSuccess() != null && result.getSuccess().isNeedsSync()) { byte[] syncMessage = createMultiDeviceSentTranscriptContent(content, Optional.of(recipient), timestamp, Collections.singletonList(result), false); sendMessage(localAddress, Optional.<UnidentifiedAccess>absent(), timestamp, syncMessage, false); } if (message.isEndSession()) { if (recipient.getUuid().isPresent()) { store.deleteAllSessions(recipient.getUuid().get().toString()); } if (recipient.getNumber().isPresent()) { store.deleteAllSessions(recipient.getNumber().get()); } if (eventListener.isPresent()) { eventListener.get().onSecurityEvent(recipient); } } return result; }
Example 2
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 5 votes |
/** * Send a message to a single recipient. * * @param recipient The message's destination. * @param message The message. * @throws UntrustedIdentityException * @throws IOException */ public SendMessageResult sendMessage(SignalServiceAddress recipient, Optional<UnidentifiedAccessPair> unidentifiedAccess, SignalServiceDataMessage message) throws UntrustedIdentityException, IOException { byte[] content = createMessageContent(message); long timestamp = message.getTimestamp(); SendMessageResult result = sendMessage(recipient, getTargetUnidentifiedAccess(unidentifiedAccess), timestamp, content, false); if (result.getSuccess() != null && result.getSuccess().isNeedsSync()) { byte[] syncMessage = createMultiDeviceSentTranscriptContent(content, Optional.of(recipient), timestamp, Collections.singletonList(result), false); sendMessage(localAddress, Optional.<UnidentifiedAccess>absent(), timestamp, syncMessage, false); } if (message.isEndSession()) { if (recipient.getUuid().isPresent()) { store.deleteAllSessions(recipient.getUuid().get().toString()); } if (recipient.getNumber().isPresent()) { store.deleteAllSessions(recipient.getNumber().get()); } if (eventListener.isPresent()) { eventListener.get().onSecurityEvent(recipient); } } return result; }
Example 3
Source File: Manager.java From signal-cli with GNU General Public License v3.0 | 4 votes |
private List<SendMessageResult> sendMessage(SignalServiceDataMessage.Builder messageBuilder, Collection<SignalServiceAddress> recipients) throws IOException { if (messagePipe == null) { messagePipe = getMessageReceiver().createMessagePipe(); } if (unidentifiedMessagePipe == null) { unidentifiedMessagePipe = getMessageReceiver().createUnidentifiedMessagePipe(); } SignalServiceDataMessage message = null; try { message = messageBuilder.build(); if (message.getGroupContext().isPresent()) { try { SignalServiceMessageSender messageSender = getMessageSender(); final boolean isRecipientUpdate = false; List<SendMessageResult> result = messageSender.sendMessage(new ArrayList<>(recipients), getAccessFor(recipients), isRecipientUpdate, message); for (SendMessageResult r : result) { if (r.getIdentityFailure() != null) { account.getSignalProtocolStore().saveIdentity(r.getAddress(), r.getIdentityFailure().getIdentityKey(), TrustLevel.UNTRUSTED); } } return result; } catch (UntrustedIdentityException e) { account.getSignalProtocolStore().saveIdentity(resolveSignalServiceAddress(e.getIdentifier()), e.getIdentityKey(), TrustLevel.UNTRUSTED); return Collections.emptyList(); } } else { // Send to all individually, so sync messages are sent correctly List<SendMessageResult> results = new ArrayList<>(recipients.size()); for (SignalServiceAddress address : recipients) { ContactInfo contact = account.getContactStore().getContact(address); if (contact != null) { messageBuilder.withExpiration(contact.messageExpirationTime); messageBuilder.withProfileKey(account.getProfileKey().serialize()); } else { messageBuilder.withExpiration(0); messageBuilder.withProfileKey(null); } message = messageBuilder.build(); if (address.matches(account.getSelfAddress())) { results.add(sendSelfMessage(message)); } else { results.add(sendMessage(address, message)); } } return results; } } finally { if (message != null && message.isEndSession()) { for (SignalServiceAddress recipient : recipients) { handleEndSession(recipient); } } account.save(); } }