Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2018-07-18 21:55:08 +02:00
parent bd15829b6a
commit 3d1f088674
2 changed files with 61 additions and 46 deletions

View file

@ -221,7 +221,9 @@ public class CallController extends BaseController {
private boolean isMultiSession = false;
private boolean hasChatSupport = false;
private boolean isVoiceOnlyCall = false;
private boolean needsPing = true;
private boolean isVoiceOnlyCall;
private boolean isFromNotification;
private Handler handler = new Handler();
@ -946,6 +948,15 @@ public class CallController extends BaseController {
.getCapabilities().getSpreedCapability()
.getFeatures().contains("chat-v2");
needsPing = !(capabilitiesOverall.getOcs().getData()
.getCapabilities() != null && capabilitiesOverall.getOcs().getData()
.getCapabilities().getSpreedCapability() != null &&
capabilitiesOverall.getOcs().getData()
.getCapabilities().getSpreedCapability()
.getFeatures() != null && capabilitiesOverall.getOcs().getData()
.getCapabilities().getSpreedCapability()
.getFeatures().contains("no-ping"));
joinRoomAndCall();
}
@ -1026,33 +1037,35 @@ public class CallController extends BaseController {
ApplicationWideCurrentRoomHolder.getInstance().setInCall(true);
ApplicationWideCurrentRoomHolder.getInstance().setUserInRoom(userEntity);
ncApi.pingCall(credentials, ApiUtils.getUrlForCallPing(baseUrl, roomToken))
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.repeatWhen(observable -> observable.delay(5000, TimeUnit.MILLISECONDS))
.takeWhile(observable -> inCall)
.retry(3, observable -> inCall)
.subscribe(new Observer<GenericOverall>() {
@Override
public void onSubscribe(Disposable d) {
pingDisposable = d;
}
if (needsPing) {
ncApi.pingCall(credentials, ApiUtils.getUrlForCallPing(baseUrl, roomToken))
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.repeatWhen(observable -> observable.delay(5000, TimeUnit.MILLISECONDS))
.takeWhile(observable -> inCall)
.retry(3, observable -> inCall)
.subscribe(new Observer<GenericOverall>() {
@Override
public void onSubscribe(Disposable d) {
pingDisposable = d;
}
@Override
public void onNext(GenericOverall genericOverall) {
@Override
public void onNext(GenericOverall genericOverall) {
}
}
@Override
public void onError(Throwable e) {
dispose(pingDisposable);
}
@Override
public void onError(Throwable e) {
dispose(pingDisposable);
}
@Override
public void onComplete() {
dispose(pingDisposable);
}
});
@Override
public void onComplete() {
dispose(pingDisposable);
}
});
}
// Start pulling signaling messages
String urlToken = null;

View file

@ -214,6 +214,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
if (args.containsKey(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL)) {
this.startCallFromNotification = args.getBoolean(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL);
}
this.voiceOnly = args.getBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, false);
}
@ -473,32 +474,33 @@ public class ChatController extends BaseController implements MessagesListAdapte
}
private void startPing() {
ncApi.pingCall(credentials, ApiUtils.getUrlForCallPing(baseUrl, roomToken))
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.repeatWhen(observable -> observable.delay(5000, TimeUnit.MILLISECONDS))
.takeWhile(observable -> inChat)
.retry(3, observable -> inChat)
.subscribe(new Observer<GenericOverall>() {
@Override
public void onSubscribe(Disposable d) {
disposableList.add(d);
}
if (!conversationUser.hasSpreedCapabilityWithName("no-ping")) {
ncApi.pingCall(credentials, ApiUtils.getUrlForCallPing(baseUrl, roomToken))
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.repeatWhen(observable -> observable.delay(5000, TimeUnit.MILLISECONDS))
.takeWhile(observable -> inChat)
.retry(3, observable -> inChat)
.subscribe(new Observer<GenericOverall>() {
@Override
public void onSubscribe(Disposable d) {
disposableList.add(d);
}
@Override
public void onNext(GenericOverall genericOverall) {
@Override
public void onNext(GenericOverall genericOverall) {
}
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
}
}
@OnClick(R.id.emptyLayout)