RxJava를 개장 한 상태에서 사용하고 있습니다. 나는 그것이 실패하거나 성공했을 때 요청에 의해 보내진 BODY/RAW를 어떻게 찾을 수 있는지 알고 싶다.추가 요청이 실패했을 때 갱신 요청 본문을 얻는 방법은 무엇입니까?
이것은 API 호출 내 컨트롤러 :
ChatMessage body = new ChatMessage();
...
//configuration of body variable is omitted.
...
chatController.sendMessage(body).subscribe(this::onSendMessageSuccess, this::onSendMessageError);
을 그리고 이러한 대답을받을 수있는 방법은 다음과 같습니다
나는 내가 사용하는 ChatMessage 클래스를 얻을 수있는 방법을 알고 싶어요private void onSendMessageSuccess(ChatRestResponse response) {
// How can I get the "ChatMessage body" sent in at first by the re
}
private void onSendMessageError(Throwable throwable) {
// How can I get the "ChatMessage body" sent in at first by the request
}
요청하십시오. 실패에
public Observable<ChatRestResponse> sendMessage(ChatMessage body) {
String accessToken = mPref.getAccesToken();
return mChatApi.sendMessage(accessToken , body)
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread());
}
@Deneb Chorny 이것은 완벽한 대답입니다 .. 실패시 응답이 없으므로 콜백의 onFailure 메서드를 사용해야합니다. –
대답은 훌륭합니다. 나는 이미 이것에 대해 알고 있었으며 답변 해 주셔서 감사합니다. 그러나 요격기를 만드는 방법이 없다고 생각합니다. 내말은. 나는 오류 또는 성공이 가능하면 원시/바디로 보낸 객체를 얻을 수 있기를 원한다. 왜? 요청을 생성하는 정확한 객체에서 UI를 업데이트하려고하기 때문입니다. –
@DenebChorny 위의 대답에서 업데이트를 참조하십시오. –