Exemple #1
0
  /** 发送震屏 */
  public void nudge(String uri) {
    ChatDialogProxy proxy = null;
    Buddy buddy = client.getFetionStore().getBuddyByUri(uri);
    int state = buddy.getPresence().getValue();
    if (state == Presence.OFFLINE) {
      println("你不能给不在线的好友发送震屏。");
      prompt();
      return;
    }

    try {
      proxy = this.client.getChatDialogProxyFactory().create(buddy);
      if (proxy.getState() == DialogState.CREATED) {
        proxy.openDialog();
      }
    } catch (Exception e) {
      println("建立对话失败!!");
      return;
    }

    proxy.sendNudgeState(
        new ActionEventListener() {
          @Override
          public void fireEevent(ActionEvent event) {
            if (event.getEventType() == ActionEventType.SUCCESS) {
              println("发送震屏成功。");
            } else {
              println("发送震屏失败!" + event.toString());
            }
          }
        });
  }
Exemple #2
0
  /**
   * 发送短信
   *
   * @param dialog
   * @param message
   */
  private void send(final Buddy buddy, final String message) {
    ChatDialogProxy proxy = null;
    try {
      proxy = this.client.getChatDialogProxyFactory().create(buddy);
    } catch (DialogException e) {
      println("建立对话失败!!");
      return;
    }
    proxy.sendChatMessage(
        Message.wrap(message),
        new ActionEventListener() {
          public void fireEevent(ActionEvent event) {
            if (event.getEventType() == ActionEventType.SUCCESS) {
              SendChatMessageSuccessEvent evt = (SendChatMessageSuccessEvent) event;
              if (evt.isSendToMobile()) {
                println("发送成功,消息已通过短信发送到对方手机!");
              } else if (evt.isSendToClient()) {
                println("发送成功,消息已通过服务直接发送到对方客户端!");
              }
            } else if (event.getEventType() == ActionEventType.FAILURE) {
              FailureEvent evt2 = (FailureEvent) event;
              switch (evt2.getFailureType()) {
                case BUDDY_NOT_FOUND:
                  System.out.println("发送失败, 该用户可能不是你好友,请尝试添加该用户为好友后再发送消息。");
                  break;
                case USER_NOT_FOUND:
                  System.out.println("发送失败, 该用户不是移动用户。");
                  break;
                case SIPC_FAIL:
                  System.out.println("发送失败, 服务器返回了错误的信息。");
                  break;
                case UNKNOWN_FAIL:
                  System.out.println("发送失败, 不知道错在哪里。");

                case REQEUST_FAIL:
                  RequestFailureEvent evt3 = (RequestFailureEvent) event;
                  System.out.println("提示:" + evt3.getReason() + ", 更多信息请访问:" + evt3.getReffer());

                default:
                  println("发送消息失败!" + event.toString());
              }
            } else {
              println("发送消息失败!" + event.toString());
            }
          }
        });
  }
Exemple #3
0
 @Override
 protected void chatInput(ChatDialogProxy dialog) {
   println(dialog.getMainBuddy().getDisplayName() + " 正在输入...");
   prompt();
 }
Exemple #4
0
 @Override
 protected void chatNugde(ChatDialogProxy dialog) {
   println(dialog.getMainBuddy().getDisplayName() + " 给你发送了一个震屏。");
   prompt();
 }