Exemple #1
0
 /* (non-Javadoc)
  * @see net.solosky.maplefetion.NotifyListener#buddyMessageRecived(net.solosky.maplefetion.bean.Buddy, java.lang.String, net.solosky.maplefetion.client.dialog.ChatDialog)
  */
 @Override
 public void buddyMessageRecived(Buddy from, Message message, ChatDialogProxy dialog) {
   if (from.getRelation() == Relation.BUDDY)
     println("[好友消息]" + from.getDisplayName() + " 说:" + message.getText());
   else println("[陌生人消息]" + from.getDisplayName() + " 说:" + message.getText());
   prompt();
 }
Exemple #2
0
 /** 发送付费短信 */
 public void dsms(String mobile, final String message) {
   final long mobileNo = Long.parseLong(mobile);
   this.client.sendDirectSMSMessage(
       mobileNo,
       Message.wrap(message),
       new ActionEventListener() {
         public void fireEevent(ActionEvent event) {
           if (event.getEventType() == ActionEventType.SUCCESS) {
             println("提示:发送给" + mobileNo + " 的短信发送成功!恭喜你的话费又少了一毛钱!!!");
           } else {
             println("[系统消息]:你发给 " + mobileNo + " 的短信  " + message + " 发送失败!");
           }
         }
       });
   System.out.println(message);
 }
Exemple #3
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 #4
0
 /** 发送手机短信消息 */
 public void sms(String uri, final String message) {
   final Buddy buddy = this.client.getFetionStore().getBuddyByUri(uri);
   if (buddy != null) {
     this.client.sendSMSMessage(
         buddy,
         Message.wrap(message),
         new ActionEventListener() {
           public void fireEevent(ActionEvent event) {
             if (event.getEventType() == ActionEventType.SUCCESS) {
               println("提示:发送给" + buddy.getDisplayName() + " 的短信发送成功!");
             } else {
               println("[系统消息]:你发给 " + buddy.getDisplayName() + " 的短信  " + message + " 发送失败!");
             }
           }
         });
   } else {
     println("找不到这个好友,请检查你的输入!");
   }
 }
Exemple #5
0
 /** 发送群消息 */
 public void say(String groupuri, String message) {
   if (groupuri == null) return;
   final Group group = this.client.getFetionStore().getGroup(groupuri);
   if (group != null) {
     GroupDialog dialog = this.client.getDialogFactory().findGroupDialog(group);
     if (dialog != null) {
       dialog.sendChatMessage(
           Message.wrap(message),
           new ActionEventListener() {
             public void fireEevent(ActionEvent event) {
               if (event.getEventType() == ActionEventType.SUCCESS) {
                 println("提示:发送给群 " + group.getName() + " 的消息发送成功!");
               } else {
                 println("提示:发送给群 " + group.getName() + " 的消息发送失败!");
               }
             }
           });
     }
   }
 }
Exemple #6
0
 /* (non-Javadoc)
  * @see net.solosky.maplefetion.NotifyListener#groupMessageRecived(net.solosky.maplefetion.bean.Group, net.solosky.maplefetion.bean.Member, java.lang.String, net.solosky.maplefetion.client.dialog.GroupDialog)
  */
 @Override
 public void groupMessageRecived(Group group, Member from, Message message, GroupDialog dialog) {
   println(
       "[群消息] 群 " + group.getName() + " 里的 " + from.getDisplayName() + " 说:" + message.getText());
   prompt();
 }
Exemple #7
0
 /**
  * 解析用户输入的命令,并调用不同的程序
  *
  * @throws Exception
  */
 public boolean dispatch(final String line) throws Exception {
   String[] cmd = line.split(" ");
   if (cmd[0].equals("welcome")) {
     this.welcome();
   } else if (cmd[0].equals("ls")) {
     this.list();
   } else if (cmd[0].equals("my")) {
     this.my();
   } else if (cmd[0].equals("group")) {
     this.group();
   } else if (cmd[0].equals("exit")) {
     this.exit();
     return false;
   } else if (cmd[0].equals("detail")) {
     if (cmd.length >= 2) this.detail(this.buddymap.get(cmd[1]));
   } else if (cmd[0].equals("enter")) {
     if (cmd.length >= 2) this.enter(this.buddymap.get(cmd[1]));
   } else if (cmd[0].equals("leave")) {
     this.leave();
   } else if (cmd[0].equals("nudge")) {
     if (cmd.length >= 2) this.nudge(this.buddymap.get(cmd[1]));
   } else if (cmd[0].equals("to")) {
     if (cmd.length >= 3) this.to(this.buddymap.get(cmd[1]), line.substring(line.indexOf(cmd[2])));
   } else if (cmd[0].equals("say")) {
     if (cmd.length >= 3)
       this.say(this.groupmap.get(cmd[1]), line.substring(line.indexOf(cmd[2])));
   } else if (cmd[0].equals("sms")) {
     if (cmd.length >= 3)
       this.sms(this.buddymap.get(cmd[1]), line.substring(line.indexOf(cmd[2])));
   } else if (cmd[0].equals("dsms")) {
     if (cmd.length >= 3) this.dsms(cmd[1], line.substring(line.indexOf(cmd[2])));
   } else if (cmd[0].equals("tel")) {
     if (cmd.length >= 3) this.tel(cmd[1], cmd[2]);
   } else if (cmd[0].equals("nickname")) {
     if (cmd.length >= 2) this.nickname(cmd[1]);
   } else if (cmd[0].equals("impresa")) {
     if (cmd.length >= 2) this.impresa(cmd[1]);
   } else if (cmd[0].equals("del")) {
     if (cmd.length >= 2) this.del(this.buddymap.get(cmd[1]));
   } else if (cmd[0].equals("newcord")) {
     if (cmd.length >= 2) this.newcord(cmd[1]);
   } else if (cmd[0].equals("delcord")) {
     if (cmd.length >= 2) this.delcord(cmd[1]);
   } else if (cmd[0].equals("cordtitle")) {
     if (cmd.length >= 3) this.cordtitle(cmd[1], cmd[2]);
   } else if (cmd[0].equals("add")) {
     if (cmd.length >= 2) this.add(cmd[1]);
   } else if (cmd[0].equals("agree")) {
     if (cmd.length >= 2) this.agree(this.buddymap.get(cmd[1]));
   } else if (cmd[0].equals("decline")) {
     if (cmd.length >= 2) this.decline(this.buddymap.get(cmd[1]));
   } else if (cmd[0].equals("self")) {
     if (cmd.length >= 2) this.self(line.substring(line.indexOf(cmd[1])));
   } else if (cmd[0].equals("localname")) {
     if (cmd.length >= 3) this.localname(this.buddymap.get(cmd[1]), cmd[2]);
   } else if (cmd[0].equals("cord")) {
     if (cmd.length >= 3) this.cord(this.buddymap.get(cmd[1]), cmd[2]);
   } else if (cmd[0].equals("presence")) {
     if (cmd.length >= 2) this.presence(cmd[1]);
   } else if (cmd[0].equals("verify")) {
     if (cmd.length >= 2) this.verify(cmd[1]);
   } else if (cmd[0].equals("help")) {
     this.help();
   } else {
     if (line != null && line.length() > 0) {
       if (this.activeChatDialog != null) {
         this.activeChatDialog.sendChatMessage(
             Message.wrap(line),
             new ActionEventListener() {
               public void fireEevent(ActionEvent event) {
                 if (event.getEventType() == ActionEventType.SUCCESS) {
                   SendChatMessageSuccessEvent evt = (SendChatMessageSuccessEvent) event;
                   if (evt.isSendToMobile()) {
                     System.out.println("发送成功,消息已通过短信发送到对方手机!");
                   } else if (evt.isSendToClient()) {
                     System.out.println("发送成功,消息已通过服务直接发送到对方客户端!");
                   }
                 } else {
                   println("发送消息失败!");
                 }
               }
             });
       } else {
         println("未知命令:" + cmd[0] + ",请检查后再输入。如需帮助请输入help。");
       }
     }
   }
   return true;
 }