Further progress in handling websocket

This commit is contained in:
Mario Danic 2018-10-11 13:44:11 +02:00
parent ca632be2ac
commit 040e6c4e3d
6 changed files with 73 additions and 1 deletions

View file

@ -76,6 +76,7 @@ import com.nextcloud.talk.models.json.signaling.Signaling;
import com.nextcloud.talk.models.json.signaling.SignalingOverall;
import com.nextcloud.talk.models.json.signaling.settings.IceServer;
import com.nextcloud.talk.models.json.signaling.settings.SignalingSettingsOverall;
import com.nextcloud.talk.models.json.websocket.HelloResponseWebSocketMessage;
import com.nextcloud.talk.utils.ApiUtils;
import com.nextcloud.talk.utils.MagicFlipView;
import com.nextcloud.talk.utils.NotificationUtils;
@ -88,6 +89,8 @@ import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder;
import com.nextcloud.talk.webrtc.MagicAudioManager;
import com.nextcloud.talk.webrtc.MagicPeerConnectionWrapper;
import com.nextcloud.talk.webrtc.MagicWebRTCUtils;
import com.nextcloud.talk.webrtc.ScarletHelper;
import com.tinder.scarlet.WebSocket;
import com.wooplr.spotlight.SpotlightView;
import org.apache.commons.lang3.StringEscapeUtils;
@ -95,6 +98,7 @@ import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.parceler.Parcels;
import org.reactivestreams.Subscription;
import org.webrtc.AudioSource;
import org.webrtc.AudioTrack;
import org.webrtc.Camera1Enumerator;
@ -131,6 +135,7 @@ import butterknife.BindView;
import butterknife.OnClick;
import butterknife.OnLongClick;
import eu.davidea.flipview.FlipView;
import io.reactivex.FlowableSubscriber;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
@ -244,6 +249,8 @@ public class CallController extends BaseController {
private SpotlightView spotlightView;
private ExternalSignalingServer externalSignalingServer;
private ExternalSignaling externalSignaling;
private ScarletHelper scarletHelper;
public CallController(Bundle args) {
super(args);
@ -911,6 +918,7 @@ public class CallController extends BaseController {
if (!TextUtils.isEmpty(signalingSettingsOverall.getOcs().getSettings().getExternalSignalingServer()) &&
!TextUtils.isEmpty(signalingSettingsOverall.getOcs().getSettings().getExternalSignalingTicket())) {
externalSignalingServer = new ExternalSignalingServer();
externalSignalingServer.setExternalSignalingServer(signalingSettingsOverall.getOcs().getSettings().getExternalSignalingServer());
externalSignalingServer.setExternalSignalingTicket(signalingSettingsOverall.getOcs().getSettings().getExternalSignalingTicket());
}
@ -1150,7 +1158,7 @@ public class CallController extends BaseController {
} else {
setUpAndInitiateScarletConnection();
}
}
@ -1165,6 +1173,57 @@ public class CallController extends BaseController {
});
}
private void setUpAndInitiateScarletConnection() {
scarletHelper = new ScarletHelper();
externalSignaling = scarletHelper.getExternalSignalingInstanceForServer(
externalSignalingServer.getExternalSignalingServer(), false);
externalSignaling.observeOnHelloBackEvent().subscribe(new FlowableSubscriber<HelloResponseWebSocketMessage>() {
@Override
public void onSubscribe(Subscription s) {
}
@Override
public void onNext(HelloResponseWebSocketMessage helloResponseWebSocketMessage) {
}
@Override
public void onError(Throwable t) {
}
@Override
public void onComplete() {
}
});
externalSignaling.observeOnConnectionOpenedEvent().subscribe(new FlowableSubscriber<WebSocket.Event.OnConnectionOpened>() {
@Override
public void onSubscribe(Subscription s) {
}
@Override
public void onNext(WebSocket.Event.OnConnectionOpened onConnectionOpened) {
externalSignaling.sendHello(scarletHelper.getAssembledHelloModel(conversationUser,
externalSignalingServer.getExternalSignalingTicket()));
}
@Override
public void onError(Throwable t) {
}
@Override
public void onComplete() {
}
});
}
@OnClick({R.id.pip_video_view, R.id.remote_renderers_layout})
public void showCallControls() {
animateCallControls(true, 0);

View file

@ -23,10 +23,13 @@ package com.nextcloud.talk.models.json.signaling;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.parceler.Parcel;
import lombok.Data;
@Data
@JsonObject
@Parcel
public class NCIceCandidate {
@JsonField(name = "sdpMLineIndex")
int sdpMLineIndex;

View file

@ -23,10 +23,13 @@ package com.nextcloud.talk.models.json.signaling;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.parceler.Parcel;
import lombok.Data;
@Data
@JsonObject
@Parcel
public class NCMessagePayload {
@JsonField(name = "type")
String type;

View file

@ -23,10 +23,13 @@ package com.nextcloud.talk.models.json.signaling;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.parceler.Parcel;
import lombok.Data;
@Data
@JsonObject
@Parcel
public class NCMessageWrapper {
@JsonField(name = "fn")
NCSignalingMessage signalingMessage;

View file

@ -23,10 +23,13 @@ package com.nextcloud.talk.models.json.signaling;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.parceler.Parcel;
import lombok.Data;
@Data
@JsonObject
@Parcel
public class NCSignalingMessage {
@JsonField(name = "from")
String from;

View file

@ -61,6 +61,7 @@ public class ScarletHelper {
@Inject
OkHttpClient okHttpClient;
public ScarletHelper() {
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
}