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 da6831a40..24fdff292 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/CallController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/CallController.java @@ -929,6 +929,7 @@ public class CallController extends BaseController { externalSignalingServer = new ExternalSignalingServer(); externalSignalingServer.setExternalSignalingServer(signalingSettingsOverall.getOcs().getSettings().getExternalSignalingServer()); externalSignalingServer.setExternalSignalingTicket(signalingSettingsOverall.getOcs().getSettings().getExternalSignalingTicket()); + setupAndInitiateWebSocketsConnection(); } if (signalingSettingsOverall.getOcs().getSettings().getStunServers() != null) { @@ -1023,7 +1024,7 @@ public class CallController extends BaseController { } private void joinRoomAndCall() { - if ("0".equals(callSession)) { + if ("0".equals(callSession) || externalSignalingServer != null) { ncApi.joinRoom(credentials, ApiUtils.getUrlForSettingMyselfAsActiveParticipant(baseUrl, roomToken), null) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) @@ -1036,8 +1037,12 @@ public class CallController extends BaseController { @Override public void onNext(CallOverall callOverall) { - callSession = callOverall.getOcs().getData().getSessionId(); - performCall(); + if (externalSignalingServer == null) { + callSession = callOverall.getOcs().getData().getSessionId(); + performCall(); + } else { + webSocketClient.joinRoomWithRoomToken(roomToken); + } } @Override @@ -1166,7 +1171,7 @@ public class CallController extends BaseController { } else { - setupAndInitiateWebSocketsConnection(); + alwaysGetPeerConnectionWrapperForSessionId(callSession, true); } } @@ -1193,11 +1198,15 @@ public class CallController extends BaseController { switch (webSocketCommunicationEvent.getType()) { case "hello": callSession = webSocketClient.getSessionId(); - webSocketClient.joinRoomWithRoomToken(roomToken); - alwaysGetPeerConnectionWrapperForSessionId(callSession, true); + joinRoomAndCall(); + break; + case "roomJoined": + if (webSocketCommunicationEvent.getHashMap().get("roomToken").equals(roomToken)) { + performCall(); + } break; case "participantsUpdate": - if (webSocketCommunicationEvent.getHashMap().get("roomId").equals(roomToken)) { + if (webSocketCommunicationEvent.getHashMap().get("roomToken").equals(roomToken)) { processUsersInRoom((List>) webSocketClient.getJobWithId(Integer.valueOf(webSocketCommunicationEvent.getHashMap().get("jobId")))); } break; diff --git a/app/src/main/java/com/nextcloud/talk/models/json/websocket/JoinedRoomOverallWebSocketMessage.java b/app/src/main/java/com/nextcloud/talk/models/json/websocket/JoinedRoomOverallWebSocketMessage.java new file mode 100644 index 000000000..64cdc790d --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/websocket/JoinedRoomOverallWebSocketMessage.java @@ -0,0 +1,36 @@ +/* + * Nextcloud Talk application + * + * @author Mario Danic + * Copyright (C) 2017-2018 Mario Danic + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.nextcloud.talk.models.json.websocket; + +import com.bluelinelabs.logansquare.annotation.JsonField; +import com.bluelinelabs.logansquare.annotation.JsonObject; + +import org.parceler.Parcel; + +import lombok.Data; + +@Data +@JsonObject +@Parcel +public class JoinedRoomOverallWebSocketMessage extends BaseWebSocketMessage { + @JsonField(name = "room") + RoomWebSocketMessage roomWebSocketMessage; +} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/websocket/RoomPropertiesWebSocketMessage.java b/app/src/main/java/com/nextcloud/talk/models/json/websocket/RoomPropertiesWebSocketMessage.java new file mode 100644 index 000000000..48b4c76f4 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/websocket/RoomPropertiesWebSocketMessage.java @@ -0,0 +1,41 @@ +/* + * Nextcloud Talk application + * + * @author Mario Danic + * Copyright (C) 2017-2018 Mario Danic + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.nextcloud.talk.models.json.websocket; + +import com.bluelinelabs.logansquare.annotation.JsonField; +import com.bluelinelabs.logansquare.annotation.JsonObject; +import com.nextcloud.talk.models.json.converters.EnumRoomTypeConverter; +import com.nextcloud.talk.models.json.rooms.Conversation; + +import org.parceler.Parcel; + +import lombok.Data; + +@Data +@Parcel +@JsonObject +public class RoomPropertiesWebSocketMessage { + @JsonField(name = "name") + String name; + + @JsonField(name = "type", typeConverter = EnumRoomTypeConverter.class) + Conversation.RoomType roomType; +} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/websocket/RoomWebSocketMessage.java b/app/src/main/java/com/nextcloud/talk/models/json/websocket/RoomWebSocketMessage.java index 34353ff36..7bc3ce454 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/websocket/RoomWebSocketMessage.java +++ b/app/src/main/java/com/nextcloud/talk/models/json/websocket/RoomWebSocketMessage.java @@ -36,4 +36,7 @@ public class RoomWebSocketMessage { @JsonField(name = "sessionid") String sessiondId; + + @JsonField(name = "properties") + RoomPropertiesWebSocketMessage roomPropertiesWebSocketMessage; } 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 98e3299fc..44dd84b56 100644 --- a/app/src/main/java/com/nextcloud/talk/webrtc/MagicWebSocketInstance.java +++ b/app/src/main/java/com/nextcloud/talk/webrtc/MagicWebSocketInstance.java @@ -33,6 +33,8 @@ import com.nextcloud.talk.models.json.websocket.CallOverallWebSocketMessage; import com.nextcloud.talk.models.json.websocket.ErrorOverallWebSocketMessage; import com.nextcloud.talk.models.json.websocket.EventOverallWebSocketMessage; import com.nextcloud.talk.models.json.websocket.HelloResponseOverallWebSocketMessage; +import com.nextcloud.talk.models.json.websocket.JoinedRoomOverallWebSocketMessage; +import com.nextcloud.talk.models.json.websocket.RoomOverallWebSocketMessage; import com.nextcloud.talk.utils.MagicMap; import org.greenrobot.eventbus.EventBus; @@ -117,8 +119,13 @@ public class MagicWebSocketInstance extends WebSocketListener { ErrorOverallWebSocketMessage errorOverallWebSocketMessage = LoganSquare.parse(text, ErrorOverallWebSocketMessage.class); break; case "room": - // Nothing for now - break; + JoinedRoomOverallWebSocketMessage joinedRoomOverallWebSocketMessage = LoganSquare.parse(text, JoinedRoomOverallWebSocketMessage.class); + if (joinedRoomOverallWebSocketMessage.getRoomWebSocketMessage().getRoomPropertiesWebSocketMessage() != null) { + HashMap joinRoomHashMap = new HashMap<>(); + joinRoomHashMap.put("roomToken", joinedRoomOverallWebSocketMessage.getRoomWebSocketMessage().getRoomId()); + eventBus.post(new WebSocketCommunicationEvent("roomJoined", joinRoomHashMap)); + } + break; case "event": // Nothing for now EventOverallWebSocketMessage eventOverallWebSocketMessage = LoganSquare.parse(text, EventOverallWebSocketMessage.class);