本文整理汇总了Java中org.whispersystems.signalservice.api.SignalServiceMessageSender.sendMessage方法的典型用法代码示例。如果您正苦于以下问题:Java SignalServiceMessageSender.sendMessage方法的具体用法?Java SignalServiceMessageSender.sendMessage怎么用?Java SignalServiceMessageSender.sendMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.whispersystems.signalservice.api.SignalServiceMessageSender
的用法示例。
在下文中一共展示了SignalServiceMessageSender.sendMessage方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onRun
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入方法依赖的package包/类
@Override
public void onRun(MasterSecret masterSecret)
throws IOException, UntrustedIdentityException
{
RecipientPreferenceDatabase database = DatabaseFactory.getRecipientPreferenceDatabase(context);
SignalServiceMessageSender messageSender = messageSenderFactory.create();
BlockedReader reader = database.readerForBlocked(database.getBlocked());
List<String> blocked = new LinkedList<>();
Recipients recipients;
while ((recipients = reader.getNext()) != null) {
if (recipients.isSingleRecipient()) {
try {
blocked.add(Util.canonicalizeNumber(context, recipients.getPrimaryRecipient().getNumber()));
} catch (InvalidNumberException e) {
Log.w(TAG, e);
}
}
}
messageSender.sendMessage(SignalServiceSyncMessage.forBlocked(new BlockedListMessage(blocked)));
}
示例2: sendUpdate
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入方法依赖的package包/类
private void sendUpdate(SignalServiceMessageSender messageSender, File contactsFile)
throws IOException, UntrustedIdentityException, NetworkException
{
if (contactsFile.length() > 0) {
FileInputStream contactsFileStream = new FileInputStream(contactsFile);
SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder()
.withStream(contactsFileStream)
.withContentType("application/octet-stream")
.withLength(contactsFile.length())
.build();
try {
messageSender.sendMessage(SignalServiceSyncMessage.forContacts(attachmentStream));
} catch (IOException ioe) {
throw new NetworkException(ioe);
}
}
}
示例3: onRun
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入方法依赖的package包/类
@Override
public void onRun(MasterSecret masterSecret) throws IOException, UntrustedIdentityException {
if (!TextSecurePreferences.isMultiDevice(context)) {
Log.w(TAG, "Not multi device...");
return;
}
List<ReadMessage> readMessages = new LinkedList<>();
for (SerializableSyncMessageId messageId : messageIds) {
readMessages.add(new ReadMessage(messageId.sender, messageId.timestamp));
}
SignalServiceMessageSender messageSender = messageSenderFactory.create();
messageSender.sendMessage(SignalServiceSyncMessage.forRead(readMessages));
}
示例4: onRun
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入方法依赖的package包/类
@Override
public void onRun() throws IOException, UntrustedIdentityException {
try {
if (!TextSecurePreferences.isMultiDevice(context)) {
Log.w(TAG, "Not multi device...");
return;
}
if (destination == null) {
Log.w(TAG, "No destination...");
return;
}
String canonicalDestination = Util.canonicalizeNumber(context, destination);
VerifiedMessage.VerifiedState verifiedState = getVerifiedState(verifiedStatus);
SignalServiceMessageSender messageSender = messageSenderFactory.create();
VerifiedMessage verifiedMessage = new VerifiedMessage(canonicalDestination, new IdentityKey(identityKey, 0), verifiedState, timestamp);
messageSender.sendMessage(SignalServiceSyncMessage.forVerified(verifiedMessage));
} catch (InvalidNumberException | InvalidKeyException e) {
throw new IOException(e);
}
}
示例5: sendUpdate
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入方法依赖的package包/类
private void sendUpdate(SignalServiceMessageSender messageSender, File contactsFile, boolean complete)
throws IOException, UntrustedIdentityException, NetworkException
{
if (contactsFile.length() > 0) {
FileInputStream contactsFileStream = new FileInputStream(contactsFile);
SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder()
.withStream(contactsFileStream)
.withContentType("application/octet-stream")
.withLength(contactsFile.length())
.build();
try {
messageSender.sendMessage(SignalServiceSyncMessage.forContacts(new ContactsMessage(attachmentStream, complete)));
} catch (IOException ioe) {
throw new NetworkException(ioe);
}
}
}
示例6: sendSyncMessage
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入方法依赖的package包/类
private void sendSyncMessage(SignalServiceSyncMessage message)
throws IOException, UntrustedIdentityException {
SignalServiceMessageSender messageSender = new SignalServiceMessageSender(serviceUrls, localIdentity.getToshiId(), localIdentity.getPassword(), signalProtocolStore, USER_AGENT, Optional.<SignalServiceMessagePipe>absent(), Optional.<SignalServiceMessageSender.EventListener>absent());
try {
messageSender.sendMessage(message);
} catch (UntrustedIdentityException e) {
// TODO: save that this is untrusted?
throw e;
}
}
示例7: sendUpdate
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入方法依赖的package包/类
private void sendUpdate(SignalServiceMessageSender messageSender, File contactsFile)
throws IOException, UntrustedIdentityException
{
FileInputStream contactsFileStream = new FileInputStream(contactsFile);
SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder()
.withStream(contactsFileStream)
.withContentType("application/octet-stream")
.withLength(contactsFile.length())
.build();
messageSender.sendMessage(SignalServiceSyncMessage.forGroups(attachmentStream));
}
示例8: onRun
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入方法依赖的package包/类
@Override
public void onRun() throws IOException, UntrustedIdentityException {
SignalServiceMessageSender messageSender = messageSenderFactory.create();
GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
GroupRecord record = groupDatabase.getGroup(groupId);
SignalServiceAttachment avatar = null;
if (record == null) {
Log.w(TAG, "No information for group record info request: " + new String(groupId));
return;
}
if (record.getAvatar() != null) {
avatar = SignalServiceAttachmentStream.newStreamBuilder()
.withContentType("image/jpeg")
.withStream(new ByteArrayInputStream(record.getAvatar()))
.withLength(record.getAvatar().length)
.build();
}
SignalServiceGroup groupContext = SignalServiceGroup.newBuilder(Type.UPDATE)
.withAvatar(avatar)
.withId(groupId)
.withMembers(record.getMembers())
.withName(record.getTitle())
.withOwner(record.getOwner())
.withAdmins(record.getAdmins())
.build();
SignalServiceDataMessage message = SignalServiceDataMessage.newBuilder()
.asGroupMessage(groupContext)
.withTimestamp(System.currentTimeMillis())
.build();
messageSender.sendMessage(new SignalServiceAddress(source), message);
}
示例9: onRun
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入方法依赖的package包/类
@Override
public void onRun() throws IOException, UntrustedIdentityException {
SignalServiceMessageSender messageSender = messageSenderFactory.create();
SignalServiceGroup group = SignalServiceGroup.newBuilder(Type.REQUEST_INFO)
.withId(groupId)
.build();
SignalServiceDataMessage message = SignalServiceDataMessage.newBuilder()
.asGroupMessage(group)
.withTimestamp(System.currentTimeMillis())
.build();
messageSender.sendMessage(new SignalServiceAddress(source), message);
}
示例10: onRun
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入方法依赖的package包/类
@Override
public void onRun() throws IOException, UntrustedIdentityException {
SignalServiceMessageSender messageSender = messageSenderFactory.create();
GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
GroupRecord record = groupDatabase.getGroup(groupId);
SignalServiceAttachment avatar = null;
if (record == null) {
Log.w(TAG, "No information for group record info request: " + new String(groupId));
return;
}
if (record.getAvatar() != null) {
avatar = SignalServiceAttachmentStream.newStreamBuilder()
.withContentType("image/jpeg")
.withStream(new ByteArrayInputStream(record.getAvatar()))
.withLength(record.getAvatar().length)
.build();
}
SignalServiceGroup groupContext = SignalServiceGroup.newBuilder(Type.UPDATE)
.withAvatar(avatar)
.withId(groupId)
.withMembers(record.getMembers())
.withName(record.getTitle())
.build();
SignalServiceDataMessage message = SignalServiceDataMessage.newBuilder()
.asGroupMessage(groupContext)
.withTimestamp(System.currentTimeMillis())
.build();
messageSender.sendMessage(new SignalServiceAddress(source), message);
}
示例11: sendSyncMessage
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入方法依赖的package包/类
private void sendSyncMessage(SignalServiceSyncMessage message)
throws IOException, UntrustedIdentityException {
SignalServiceMessageSender messageSender = new SignalServiceMessageSender(serviceConfiguration, username, password,
deviceId, signalProtocolStore, USER_AGENT, Optional.fromNullable(messagePipe), Optional.<SignalServiceMessageSender.EventListener>absent());
try {
messageSender.sendMessage(message);
} catch (UntrustedIdentityException e) {
signalProtocolStore.saveIdentity(e.getE164Number(), e.getIdentityKey(), TrustLevel.UNTRUSTED);
throw e;
}
}