在请求处理过程中如何防止客户端重试呼叫?

时间:2019-01-15 09:43:41

标签: http http-headers android-volley android-mediaplayer

我有一个流API,其工作方式如下:

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, AlertController } from 'ionic-angular';
import { RestapiProvider } from '../../providers/restapi/restapi';
import { ListPage } from '../list/list';
import { FrontPage } from '../front/front';
import { CartPage } from './../cart/cart';
import {Validators, FormBuilder, FormGroup } from '@angular/forms';
import { MyApp } from './../../app/app.component';

@IonicPage()
@Component({
  selector: 'page-loginpage',
  templateUrl: 'loginpage.html',
})
export class LoginpagePage {
  todo : FormGroup;
  responseData : any;
  userData = {"username": "", "password": ""};
  constructor(public navCtrl: NavController, public navParams: NavParams,
    public restProvider: RestapiProvider, private formBuilder: FormBuilder, private alertCtrl: AlertController) {
      this.todo = this.formBuilder.group({
        username: ['', Validators.required],
        password: ['', Validators.required],
      });
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad LoginpagePage');
  }

    getloginUsers(){
      this.restProvider.getUsers(this.userData, 'user_Login').subscribe((data) => {
        console.log(data);
        if (data) {
          this.responseData = data;
          console.log(this.responseData.msg.name);
          if (this.responseData.status === 'success') {
            this.navCtrl.push(MyApp,{
              param1: this.responseData.msg.name,
            });
          }
          else{
            this.presentAlert();
          }
        }
      });

 }

 presentAlert() {
  let alert = this.alertCtrl.create({
    title: 'Incorrect Username Or Password',
    buttons: ['Dismiss']
  });
  alert.present();
}

 cardpage2()
 {
   this.navCtrl.push(CartPage);
 }
 }

在这种情况下,Media Player具有它自己的HTTP调用机制,关于Volley API调用,我也观察到了同样的情况,但是我们有重试策略,在该策略中,我们将超时时间增加到大于服务器处理平均时间的值。

如何通知客户正在处理您的请求,请稍候?服务器可以发送给客户端的HTTP标头是否需要等待一段时间?

0 个答案:

没有答案