Package net.solosky.maplefetion.client.dialog

Examples of net.solosky.maplefetion.client.dialog.ServerDialog


      if(this.context.getFetionUser().getFetionId()==0){
        throw new IllegalArgumentException("Invalid fetion id. if disabled SSI sign, you must login with fetion id..");
      }
     
      this.updateLoginState(LoginState.SIPC_REGISTER_DOING, null);
    ServerDialog serverDialog = this.context.getDialogFactory().createServerDialog();
        serverDialog.openDialog();
       
        ActionEventFuture future = new ActionEventFuture();
      ActionEventListener listener = new FutureActionEventListener(future);
     
      //注册服务器
      serverDialog.register(presence, listener);
      Dialog.assertActionEvent(future.waitActionEventWithException(), ActionEventType.SUCCESS);
     
      //用户验证
      future.clear();
      serverDialog.userAuth(presence, listener);
      ActionEvent event = future.waitActionEventWithoutException();
      if(event.getEventType()==ActionEventType.SUCCESS){
        this.updateLoginState(LoginState.SIPC_REGISGER_SUCCESS, null);
      }else if(event.getEventType()==ActionEventType.FAILURE){
        FailureEvent evt = (FailureEvent) event;
View Full Code Here


     */
    private void getContactsInfo() throws IllegalResponseException, RequestTimeoutException, TransferException, SystemException, InterruptedException
    {
      ActionEventFuture future = new ActionEventFuture();
      ActionEventListener listener = new FutureActionEventListener(future);
      ServerDialog dialog = this.context.getDialogFactory().getServerDialog();
    this.updateLoginState(LoginState.GET_CONTACTS_INFO_DOING, null);
   
       
        //订阅异步通知
    if(this.context.getFetionStore().getBuddyList().size()>0){
          future.clear();
          dialog.subscribeBuddyNotify(listener);
          Dialog.assertActionEvent(future.waitActionEventWithException(), ActionEventType.SUCCESS);
    }
       
        this.updateLoginState(LoginState.GET_CONTACTS_INFO_SUCCESS, null);
    }
View Full Code Here

     */
    private void getGroupsInfo() throws IllegalResponseException, RequestTimeoutException, TransferException, SystemException, InterruptedException
    {
      ActionEventFuture future = new ActionEventFuture();
      ActionEventListener listener = new FutureActionEventListener(future);
      ServerDialog dialog = this.context.getDialogFactory().getServerDialog();
      StoreVersion storeVersion   = this.context.getFetionStore().getStoreVersion();
      StoreVersion userVersion    = this.context.getFetionUser().getStoreVersion();

      this.updateLoginState(LoginState.GET_GROUPS_INFO_DOING, null);
        //获取群列表
        future.clear();
        dialog.getGroupList(listener);
        Dialog.assertActionEvent(future.waitActionEventWithException(), ActionEventType.SUCCESS);
       
    //如果群列表为空,就不发送下面的一些请求了
    FetionStore store = this.context.getFetionStore();
    if(store.getGroupList().size()==0){
      logger.debug("The group list is empty, group dialog login is skipped.");
      return;
    }

        //如果当前存储版本和服务器相同,就不获取群信息和群成员列表,
        //TODO ..这里只是解决了重新登录的问题,事实上这里问题很大,群信息分成很多
        //用户加入的群列表 groupListVersion
        //某群的信息      groupInfoVersion
        //群成员列表      groupMemberListVersion
        //暂时就这样,逐步完善中.....
        logger.debug("GroupListVersion: server="+userVersion.getGroupVersion()+", local="+storeVersion.getGroupVersion());
        if(storeVersion.getGroupVersion()!=userVersion.getGroupVersion()) {
      //更新存储版本
      storeVersion.setGroupVersion(userVersion.getGroupVersion());
          //获取群信息
          future.clear();
          dialog.getGroupsInfo(this.context.getFetionStore().getGroupList(), listener);
          Dialog.assertActionEvent(future.waitActionEventWithException(), ActionEventType.SUCCESS);
       
          //获取群成员
          future.clear();
          dialog.getMemberList(this.context.getFetionStore().getGroupList(), listener);
          Dialog.assertActionEvent(future.waitActionEventWithException(), ActionEventType.SUCCESS);
         
          storeVersion.setGroupVersion(userVersion.getGroupVersion());
        }
       
View Full Code Here

  {
    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

TOP

Related Classes of net.solosky.maplefetion.client.dialog.ServerDialog

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.