mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-24 05:55:39 +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 = new ExternalSignalingServer();
|
||||||
externalSignalingServer.setExternalSignalingServer(signalingSettingsOverall.getOcs().getSettings().getExternalSignalingServer());
|
externalSignalingServer.setExternalSignalingServer(signalingSettingsOverall.getOcs().getSettings().getExternalSignalingServer());
|
||||||
externalSignalingServer.setExternalSignalingTicket(signalingSettingsOverall.getOcs().getSettings().getExternalSignalingTicket());
|
externalSignalingServer.setExternalSignalingTicket(signalingSettingsOverall.getOcs().getSettings().getExternalSignalingTicket());
|
||||||
|
setupAndInitiateWebSocketsConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (signalingSettingsOverall.getOcs().getSettings().getStunServers() != null) {
|
if (signalingSettingsOverall.getOcs().getSettings().getStunServers() != null) {
|
||||||
|
@ -1023,7 +1024,7 @@ public class CallController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void joinRoomAndCall() {
|
private void joinRoomAndCall() {
|
||||||
if ("0".equals(callSession)) {
|
if ("0".equals(callSession) || externalSignalingServer != null) {
|
||||||
ncApi.joinRoom(credentials, ApiUtils.getUrlForSettingMyselfAsActiveParticipant(baseUrl, roomToken), null)
|
ncApi.joinRoom(credentials, ApiUtils.getUrlForSettingMyselfAsActiveParticipant(baseUrl, roomToken), null)
|
||||||
.subscribeOn(Schedulers.newThread())
|
.subscribeOn(Schedulers.newThread())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
@ -1036,8 +1037,12 @@ public class CallController extends BaseController {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(CallOverall callOverall) {
|
public void onNext(CallOverall callOverall) {
|
||||||
callSession = callOverall.getOcs().getData().getSessionId();
|
if (externalSignalingServer == null) {
|
||||||
performCall();
|
callSession = callOverall.getOcs().getData().getSessionId();
|
||||||
|
performCall();
|
||||||
|
} else {
|
||||||
|
webSocketClient.joinRoomWithRoomToken(roomToken);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1166,7 +1171,7 @@ public class CallController extends BaseController {
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
setupAndInitiateWebSocketsConnection();
|
alwaysGetPeerConnectionWrapperForSessionId(callSession, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1193,11 +1198,15 @@ public class CallController extends BaseController {
|
||||||
switch (webSocketCommunicationEvent.getType()) {
|
switch (webSocketCommunicationEvent.getType()) {
|
||||||
case "hello":
|
case "hello":
|
||||||
callSession = webSocketClient.getSessionId();
|
callSession = webSocketClient.getSessionId();
|
||||||
webSocketClient.joinRoomWithRoomToken(roomToken);
|
joinRoomAndCall();
|
||||||
alwaysGetPeerConnectionWrapperForSessionId(callSession, true);
|
break;
|
||||||
|
case "roomJoined":
|
||||||
|
if (webSocketCommunicationEvent.getHashMap().get("roomToken").equals(roomToken)) {
|
||||||
|
performCall();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "participantsUpdate":
|
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"))));
|
processUsersInRoom((List<HashMap<String, Object>>) webSocketClient.getJobWithId(Integer.valueOf(webSocketCommunicationEvent.getHashMap().get("jobId"))));
|
||||||
}
|
}
|
||||||
break;
|
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")
|
@JsonField(name = "sessionid")
|
||||||
String sessiondId;
|
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.ErrorOverallWebSocketMessage;
|
||||||
import com.nextcloud.talk.models.json.websocket.EventOverallWebSocketMessage;
|
import com.nextcloud.talk.models.json.websocket.EventOverallWebSocketMessage;
|
||||||
import com.nextcloud.talk.models.json.websocket.HelloResponseOverallWebSocketMessage;
|
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 com.nextcloud.talk.utils.MagicMap;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
@ -117,8 +119,13 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||||
ErrorOverallWebSocketMessage errorOverallWebSocketMessage = LoganSquare.parse(text, ErrorOverallWebSocketMessage.class);
|
ErrorOverallWebSocketMessage errorOverallWebSocketMessage = LoganSquare.parse(text, ErrorOverallWebSocketMessage.class);
|
||||||
break;
|
break;
|
||||||
case "room":
|
case "room":
|
||||||
// Nothing for now
|
JoinedRoomOverallWebSocketMessage joinedRoomOverallWebSocketMessage = LoganSquare.parse(text, JoinedRoomOverallWebSocketMessage.class);
|
||||||
break;
|
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":
|
case "event":
|
||||||
// Nothing for now
|
// Nothing for now
|
||||||
EventOverallWebSocketMessage eventOverallWebSocketMessage = LoganSquare.parse(text, EventOverallWebSocketMessage.class);
|
EventOverallWebSocketMessage eventOverallWebSocketMessage = LoganSquare.parse(text, EventOverallWebSocketMessage.class);
|
||||||
|
|
Loading…
Reference in a new issue