Package net.solosky.maplefetion

Examples of net.solosky.maplefetion.LoginState


     * @see net.solosky.maplefetion.client.SSISign#signIn(net.solosky.maplefetion.bean.User, net.solosky.maplefetion.bean.VerifyImage)
     */
    @Override
    public LoginState signIn(User user, VerifyImage img)
    {
      LoginState state = null;
    String url = this.buildUrl(user, img);
    try {
          URL doUrl = new URL(url);
          HttpsURLConnection conn = (HttpsURLConnection) doUrl.openConnection();
          int status = conn.getResponseCode();
View Full Code Here


      });
      //禁用掉群,登录可以变得快一点
      client.enableGroup(false);   
     
      //这里为了编程方便使用了同步登录,当然推荐异步登录,使用登录状态回调函数来完成登录成功后的操作
      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()){
              System.out.println("发送成功,消息已通过短信发送到对方手机!");
            }else if(evt.isSendToClient()){
              System.out.println("发送成功,消息已通过服务直接发送到对方客户端!");
            }
            break;
           
          case 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.getReason());
               
              default:
                System.out.println("发送消息失败!"+event.toString());
            }
            break;
         
          /* 以下三个错误状态是在异步发送消息的情况才会发生,
           * 为了方便处理,使用waitActionEventWithException()同步的情况下,这三个错误是通过异常来处理的
           * 也就是在waitActionEvent的时候就会判断是否出现了这三个错误,如果出现了就会抛出相应的异常
           * 而waitActionEventWithoutException()不会抛出异常,会把这些错误作为操作事件返回
           */
          case SYSTEM_ERROR:
            System.out.println("发送失败, 客户端内部错误。");
            break;
          case TIMEOUT:
            System.out.println("发送失败, 超时");
            break;
          case TRANSFER_ERROR:
            System.out.println("发送失败, 超时");
       
             
              //无论发送成功还是失败,因为登录了,就必须退出,释放线程资源,否则客户端不会主动退出
              //如果登录失败了,客户端会主动释放线程资源,不需要退出
              System.out.print("正在退出客户端...");
              client.logout();
              System.out.println("已经退出。");
             
      }else if(state==LoginState.SSI_AUTH_FAIL){
        System.out.println("你输入的手机号或者密码不对,请检查后重试!");
      }else if(state==LoginState.SSI_CONNECT_FAIL){
        System.out.println("SSI连接失败!!");
      }else if(state==LoginState.SIPC_CONNECT_FAIL){
        System.out.println("SIPC服务器连接失败!!");
      }else if(state==LoginState.LOGIN_CANCELED){
        //取消了登录
      }else {
        System.out.println("登录失败,原因:"+state.name());
      }
    }
   
  }
View Full Code Here

   * @throws IOException
   * @throws ParseException
   */
  private LoginState signIn(User user, String pid, String pic)
  {
    LoginState state = null;
    String url = this.buildUrl(user, pid, pic);
    try {
          HttpsURLConnection conn = (HttpsURLConnection) this.getConnection(url);
          conn.addRequestProperty("User-Agent", "IIC2.0/PC "+FetionClient.PROTOCOL_VERSION);
          logger.debug("SSISignIn: status="+Integer.toString(conn.getResponseCode()));
View Full Code Here

    private void SSISign() throws LoginException
    {
      this.updateLoginState(LoginState.SSI_SIGN_IN_DOING, null);
     
      //第一次尝试不用验证码登录
      LoginState state = this.signAction.signIn(this.context.getFetionUser());
      //如果结果为需要验证或者验证失败,重复验证,直到SSI的结果为其他结果为止
      while(state==LoginState.SSI_NEED_VERIFY || state==LoginState.SSI_VERIFY_FAIL) {
            try {
              VerifyImage img = this.ssiVerifyWaiter.waitObject();
              state = this.signAction.signIn(this.context.getFetionUser(), img);
View Full Code Here

TOP

Related Classes of net.solosky.maplefetion.LoginState

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.