Android - 如何使用Retrofit多次调用相同的API

时间:2017-12-05 17:47:58

标签: android

我想要做的是多次调用相同的API服务:

  @POST("./")
  Observable<GetUploadPartResponse> uploadPart(@Header("Authorization") String auth, @Body RequestBody part);

private void doCall(){

     mService.uploadPart(auth, body)
            .subscribeOn(Schedulers.newThread())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Subscriber<GetUploadPartResponse>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {

                }

                @Override
                public void onNext(GetUploadPartResponse response) {


            });
   }

我想做这样的事情:

  for(int i = 0; i < multipleTimes; i++){
     doCall();
  }

问题是当multipleTimes为30且更大时,它会给我一个SocketTimeoutException。

0 个答案:

没有答案