Package net.solosky.maplefetion.event.action

Examples of net.solosky.maplefetion.event.action.ActionEventFuture


  private ActionEvent getScheduleSMSInfo()
  {
    Iterator<ScheduleSMS> it = this.context.getFetionStore().getScheduleSMSList().iterator();
    int pageSize = 20;
    ArrayList <ScheduleSMS> readyList = new ArrayList<ScheduleSMS>();
    ActionEventFuture future = new ActionEventFuture();
    ServerDialog dialog = this.context.getDialogFactory().getServerDialog();
   
    //迭代所有的定时短信列表,并在每20个发起一次获取定时短信详细内容的请求
    while(it.hasNext()){
      ScheduleSMS sc = it.next();
      readyList.add(sc);
      if(readyList.size()==20){
        future.clear();
        dialog.getScheduleSMSInfo(readyList, future);
        ActionEvent event = future.waitActionEventWithoutException();
        if(event.getEventType()==ActionEventType.SUCCESS){
          readyList.clear();    //成功继续下一次请求
        }else{
          return event;      //失败返回这个错误事件
        }
      }
    }
   
    //迭代完了,可能仍有部分短信没有请求,检查下请求列表,如果不为空,则继续请求
    if(readyList.size()>0){
      future.clear();
      dialog.getScheduleSMSInfo(readyList, future);
      return future.waitActionEventWithoutException();
    }else{
      return new SuccessEvent();    //成功
    }
  }
View Full Code Here


      //这里为了编程方便使用了同步登录,当然推荐异步登录,使用登录状态回调函数来完成登录成功后的操作
      LoginState state = client.syncLogin();
      if(state==LoginState.LOGIN_SUCCESS){  //登录成功
        System.out.println("登录成功,正在发送消息至 "+args[2]+",请稍候...");                     
         
        ActionEventFuture future = new ActionEventFuture()//建立一个Future来等待操作事件     
        client.sendChatMessage(Long.parseLong(args[2]), new Message(args[3]), future);
        ActionEvent event = future.waitActionEventWithoutException()//等待操作完成事件
        switch(event.getEventType()){
         
          case SUCCESS:
            SendChatMessageSuccessEvent evt = (SendChatMessageSuccessEvent) event;
            if(evt.isSendToMobile()){
View Full Code Here

   * @return 操作结果等待对象, 可以在这个对象上调用waitStatus()等待操作结果
   */
  public ActionEventFuture sendChatMessage(Buddy toBuddy, Message message)
  {
    this.ensureOnline();
    ActionEventFuture future = new ActionEventFuture();
    this.sendChatMessage(toBuddy, message, new FutureActionEventListener(future));
    return future;
  }
View Full Code Here

TOP

Related Classes of net.solosky.maplefetion.event.action.ActionEventFuture

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.