当前位置: 首页>>代码示例>>Java>>正文


Java SignalServiceMessageSender.sendMessage方法代码示例

本文整理汇总了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)));
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:24,代码来源:MultiDeviceBlockedUpdateJob.java

示例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);
    }
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:19,代码来源:MultiDeviceContactUpdateJob.java

示例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));
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:17,代码来源:MultiDeviceReadUpdateJob.java

示例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);
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:24,代码来源:MultiDeviceVerifiedUpdateJob.java

示例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);
    }
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:19,代码来源:MultiDeviceContactUpdateJob.java

示例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;
    }
}
 
开发者ID:toshiapp,项目名称:toshi-headless-client,代码行数:11,代码来源:Manager.java

示例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));
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:13,代码来源:MultiDeviceGroupUpdateJob.java

示例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);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:38,代码来源:PushGroupUpdateJob.java

示例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);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:16,代码来源:RequestGroupInfoJob.java

示例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);
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:36,代码来源:PushGroupUpdateJob.java

示例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;
    }
}
 
开发者ID:AsamK,项目名称:signal-cli,代码行数:12,代码来源:Manager.java


注:本文中的org.whispersystems.signalservice.api.SignalServiceMessageSender.sendMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。