mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-23 21:45:42 +03:00
More progress in websocket implementation
This commit is contained in:
parent
f6b1dca677
commit
bd303a1d00
5 changed files with 105 additions and 9 deletions
|
@ -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) {
|
||||
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<HashMap<String, Object>>) webSocketClient.getJobWithId(Integer.valueOf(webSocketCommunicationEvent.getHashMap().get("jobId"))));
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
|
@ -36,4 +36,7 @@ public class RoomWebSocketMessage {
|
|||
|
||||
@JsonField(name = "sessionid")
|
||||
String sessiondId;
|
||||
|
||||
@JsonField(name = "properties")
|
||||
RoomPropertiesWebSocketMessage roomPropertiesWebSocketMessage;
|
||||
}
|
||||
|
|
|
@ -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,7 +119,12 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
|||
ErrorOverallWebSocketMessage errorOverallWebSocketMessage = LoganSquare.parse(text, ErrorOverallWebSocketMessage.class);
|
||||
break;
|
||||
case "room":
|
||||
// Nothing for now
|
||||
JoinedRoomOverallWebSocketMessage joinedRoomOverallWebSocketMessage = LoganSquare.parse(text, JoinedRoomOverallWebSocketMessage.class);
|
||||
if (joinedRoomOverallWebSocketMessage.getRoomWebSocketMessage().getRoomPropertiesWebSocketMessage() != null) {
|
||||
HashMap<String, String> joinRoomHashMap = new HashMap<>();
|
||||
joinRoomHashMap.put("roomToken", joinedRoomOverallWebSocketMessage.getRoomWebSocketMessage().getRoomId());
|
||||
eventBus.post(new WebSocketCommunicationEvent("roomJoined", joinRoomHashMap));
|
||||
}
|
||||
break;
|
||||
case "event":
|
||||
// Nothing for now
|
||||
|
|
Loading…
Reference in a new issue