Example #1
0
  private void TL_RpcError(TL.Object obj) {
    int code = obj.getInt("error_code");
    String msg = obj.getString("error_message");

    Common.logError(String.format("rpc_error: %s (%d)\n", msg, code));

    Message req_msg = TLMessage.get(req_msg_id);
    if (req_msg == null) return;
    Common.logError("message object: " + req_msg.obj.name + ":" + req_msg.obj.type);

    int idx = msg.indexOf("_MIGRATE_");
    if (idx > 0) {
      String type = msg.substring(0, idx);

      String num = msg.substring(idx + 9);
      if ((idx = num.indexOf(":")) > 0) num = num.substring(0, idx);
      int dc_id = Integer.parseInt(num);
      Common.logError("redirect to dc: " + dc_id);

      MTProto m = MTProto.getConnection(dc_id, cb, reuseFlag);
      cb.onRedirect(m);
      if (type.equals("PHONE") || type.equals("NETWORK") || type.equals("USER")) dc_this = dc_id;

      m.sendMessage(req_msg);
    }
  }