예제 #1
0
  private void TL_BadMsgNotification(TL.Object obj) {
    int error_code = obj.getInt("error_code");

    Message msg = TLMessage.get(obj.getLong("bad_msg_id"));
    Common.logError("bad_msg: " + error_code + " " + msg.obj.name + ":" + msg.obj.type);

    if (error_code == 16 || error_code == 17) {
      time_delta = (int) ((cur_message_id >> 32) - Common.getUnixTime());
      last_message_id = 0;
    }

    if (error_code == 32 || error_code == 33) {
      Common.logError("cur seq: " + cur_msg_seq);
      Common.logError("old seq: " + seqno);
      if (!bad_seq) {
        session = GEN_session_id();
        seqno = 0;
        send_ping();
        bad_seq = true;
      }

      // seqno = cur_msg_seq + (cur_msg_seq % 2) + 100;
      //	session = GEN_session_id();
      //	seqno = 0;
    }

    if (obj.id == 0xedab447b) { // bad_server_salt
      server_salt = obj.getLong("new_server_salt");
      dcState.set("server_salt", server_salt);
    }

    retry(obj.getLong("bad_msg_id"));
  }
예제 #2
0
  public void onAuthorized() {
    dcState.set("auth_key", auth_key);
    dcState.set("server_salt", server_salt);

    long upd_delta = (long) Common.getUnixTime() - (long) dc_date;
    if (Main.mtp == this && upd_delta > 5 * 60) api_help_getConfig();

    if (!bind && this != Main.mtp) {
      final MTProto m = this;
      Common.logError("exportAuthorization");
      Main.mtp.api(
          new TL.OnResultRPC() {
            @Override
            public void onResultRPC(TL.Object result, Object param, boolean error) {
              if (!error) return;
              if (result.id != 0xdf969c2d) return; // auth.ExportedAuthorization
              Common.logError("importAuthorization");
              m.api(
                  null,
                  null,
                  "auth.importAuthorization",
                  result.getInt("id"),
                  result.getBytes("bytes"));
            }
          },
          null,
          "auth.exportAuthorization",
          dcState.getInt("id"));
      return;
    }

    if (bind) cb.onBind();
    send_queue();
  }