From c48e9e01a2482f6ef60d11b011991da2aa771a5c Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Fri, 21 Jun 2019 11:32:34 +0200 Subject: [PATCH] Improve sending nick Signed-off-by: Mario Danic --- .../talk/controllers/CallController.java | 28 +++++++++++++++---- .../talk/webrtc/MagicWebSocketInstance.java | 1 - 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/CallController.java b/app/src/main/java/com/nextcloud/talk/controllers/CallController.java index 010d7b840..bcdd62184 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/CallController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/CallController.java @@ -1722,19 +1722,35 @@ public class CallController extends BaseController { nickChangedPayload.put("userid", conversationUser.getUserId()); nickChangedPayload.put("name", conversationUser.getDisplayName()); dataChannelMessage.setPayload(nickChangedPayload); + final MagicPeerConnectionWrapper magicPeerConnectionWrapper; for (int i = 0; i < magicPeerConnectionWrapperList.size(); i++) { if (magicPeerConnectionWrapperList.get(i).isMCUPublisher()) { - int finalI = i; + magicPeerConnectionWrapper = magicPeerConnectionWrapperList.get(i); Observable .interval(1, TimeUnit.SECONDS) - .repeat() + .repeatWhen() -> !isConnectionEstablished() || isBeingDestroyed() || isDestroyed() || !MerlinTheWizard.isConnectedToInternet()) .observeOn(Schedulers.io()) - .doOnNext(new Consumer() { + .subscribe(new Observer() { @Override - public void accept(Long aLong) { - magicPeerConnectionWrapperList.get(finalI).sendNickChannelData(dataChannelMessage); + public void onSubscribe(Disposable d) { + } - }).subscribe(); + + @Override + public void onNext(Long aLong) { + magicPeerConnectionWrapper.sendNickChannelData(dataChannelMessage); + } + + @Override + public void onError(Throwable e) { + + } + + @Override + public void onComplete() { + + } + }); break; } diff --git a/app/src/main/java/com/nextcloud/talk/webrtc/MagicWebSocketInstance.java b/app/src/main/java/com/nextcloud/talk/webrtc/MagicWebSocketInstance.java index c42072239..4b1eaf4cf 100644 --- a/app/src/main/java/com/nextcloud/talk/webrtc/MagicWebSocketInstance.java +++ b/app/src/main/java/com/nextcloud/talk/webrtc/MagicWebSocketInstance.java @@ -137,7 +137,6 @@ public class MagicWebSocketInstance extends WebSocketListener { @Override public void onMessage(WebSocket webSocket, String text) { - Log.d(TAG, "ReceivingBEFORE : " + webSocket.toString() + " " + text); if (webSocket == internalWebSocket) { Log.d(TAG, "Receiving : " + webSocket.toString() + " " + text); LoggingUtils.writeLogEntryToFile(context,