mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 03:29:28 +01:00
Provide federation values when joining a room in the external signaling
The "federation" values are used by the external signaling server to establish a connection with the remote signaling server in a federated room. For now this is applied only in calls; when the room is joined in the chat view again after a call it will still join it in the old way, without federation properties, which will cause the connection with the remote signaling server to be closed. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
parent
f3c7913f16
commit
86b06488c3
@ -1632,7 +1632,8 @@ class CallActivity : CallBaseActivity() {
|
|||||||
|
|
||||||
private fun callOrJoinRoomViaWebSocket() {
|
private fun callOrJoinRoomViaWebSocket() {
|
||||||
if (hasExternalSignalingServer) {
|
if (hasExternalSignalingServer) {
|
||||||
webSocketClient!!.joinRoomWithRoomTokenAndSession(roomToken!!, callSession)
|
webSocketClient!!.joinRoomWithRoomTokenAndSession(roomToken!!, callSession,
|
||||||
|
externalSignalingServer!!.federation)
|
||||||
} else {
|
} else {
|
||||||
performCall()
|
performCall()
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,10 @@ class RoomWebSocketMessage(
|
|||||||
@JsonField(name = ["sessionid"])
|
@JsonField(name = ["sessionid"])
|
||||||
var sessionId: String? = null,
|
var sessionId: String? = null,
|
||||||
@JsonField(name = ["properties"])
|
@JsonField(name = ["properties"])
|
||||||
var roomPropertiesWebSocketMessage: RoomPropertiesWebSocketMessage? = null
|
var roomPropertiesWebSocketMessage: RoomPropertiesWebSocketMessage? = null,
|
||||||
|
@JsonField(name = ["federation"])
|
||||||
|
var roomFederationWebSocketMessage: RoomFederationWebSocketMessage? = null
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
||||||
constructor() : this(null, null, null)
|
constructor() : this(null, null, null, null)
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import android.util.Log;
|
|||||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||||
import com.nextcloud.talk.data.user.model.User;
|
import com.nextcloud.talk.data.user.model.User;
|
||||||
import com.nextcloud.talk.models.json.signaling.NCSignalingMessage;
|
import com.nextcloud.talk.models.json.signaling.NCSignalingMessage;
|
||||||
|
import com.nextcloud.talk.models.json.signaling.settings.FederationSettings;
|
||||||
import com.nextcloud.talk.models.json.websocket.ActorWebSocketMessage;
|
import com.nextcloud.talk.models.json.websocket.ActorWebSocketMessage;
|
||||||
import com.nextcloud.talk.models.json.websocket.AuthParametersWebSocketMessage;
|
import com.nextcloud.talk.models.json.websocket.AuthParametersWebSocketMessage;
|
||||||
import com.nextcloud.talk.models.json.websocket.AuthWebSocketMessage;
|
import com.nextcloud.talk.models.json.websocket.AuthWebSocketMessage;
|
||||||
@ -19,6 +20,7 @@ import com.nextcloud.talk.models.json.websocket.CallOverallWebSocketMessage;
|
|||||||
import com.nextcloud.talk.models.json.websocket.CallWebSocketMessage;
|
import com.nextcloud.talk.models.json.websocket.CallWebSocketMessage;
|
||||||
import com.nextcloud.talk.models.json.websocket.HelloOverallWebSocketMessage;
|
import com.nextcloud.talk.models.json.websocket.HelloOverallWebSocketMessage;
|
||||||
import com.nextcloud.talk.models.json.websocket.HelloWebSocketMessage;
|
import com.nextcloud.talk.models.json.websocket.HelloWebSocketMessage;
|
||||||
|
import com.nextcloud.talk.models.json.websocket.RoomFederationWebSocketMessage;
|
||||||
import com.nextcloud.talk.models.json.websocket.RoomOverallWebSocketMessage;
|
import com.nextcloud.talk.models.json.websocket.RoomOverallWebSocketMessage;
|
||||||
import com.nextcloud.talk.models.json.websocket.RoomWebSocketMessage;
|
import com.nextcloud.talk.models.json.websocket.RoomWebSocketMessage;
|
||||||
import com.nextcloud.talk.utils.ApiUtils;
|
import com.nextcloud.talk.utils.ApiUtils;
|
||||||
@ -128,12 +130,21 @@ public class WebSocketConnectionHelper {
|
|||||||
return helloOverallWebSocketMessage;
|
return helloOverallWebSocketMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
RoomOverallWebSocketMessage getAssembledJoinOrLeaveRoomModel(String roomId, String sessionId) {
|
RoomOverallWebSocketMessage getAssembledJoinOrLeaveRoomModel(String roomId, String sessionId,
|
||||||
|
FederationSettings federation) {
|
||||||
RoomOverallWebSocketMessage roomOverallWebSocketMessage = new RoomOverallWebSocketMessage();
|
RoomOverallWebSocketMessage roomOverallWebSocketMessage = new RoomOverallWebSocketMessage();
|
||||||
roomOverallWebSocketMessage.setType("room");
|
roomOverallWebSocketMessage.setType("room");
|
||||||
RoomWebSocketMessage roomWebSocketMessage = new RoomWebSocketMessage();
|
RoomWebSocketMessage roomWebSocketMessage = new RoomWebSocketMessage();
|
||||||
roomWebSocketMessage.setRoomId(roomId);
|
roomWebSocketMessage.setRoomId(roomId);
|
||||||
roomWebSocketMessage.setSessionId(sessionId);
|
roomWebSocketMessage.setSessionId(sessionId);
|
||||||
|
if (federation != null) {
|
||||||
|
RoomFederationWebSocketMessage roomFederationWebSocketMessage = new RoomFederationWebSocketMessage();
|
||||||
|
roomFederationWebSocketMessage.setSignaling(federation.getServer());
|
||||||
|
roomFederationWebSocketMessage.setUrl(federation.getNextcloudServer() + "/ocs/v2.php/apps/spreed/api/v3/signaling/backend");
|
||||||
|
roomFederationWebSocketMessage.setRoomid(federation.getRoomId());
|
||||||
|
roomFederationWebSocketMessage.setToken(federation.getHelloAuthParams().getToken());
|
||||||
|
roomWebSocketMessage.setRoomFederationWebSocketMessage(roomFederationWebSocketMessage);
|
||||||
|
}
|
||||||
roomOverallWebSocketMessage.setRoomWebSocketMessage(roomWebSocketMessage);
|
roomOverallWebSocketMessage.setRoomWebSocketMessage(roomWebSocketMessage);
|
||||||
return roomOverallWebSocketMessage;
|
return roomOverallWebSocketMessage;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import com.nextcloud.talk.events.WebSocketCommunicationEvent
|
|||||||
import com.nextcloud.talk.models.json.participants.Participant
|
import com.nextcloud.talk.models.json.participants.Participant
|
||||||
import com.nextcloud.talk.models.json.participants.Participant.ActorType
|
import com.nextcloud.talk.models.json.participants.Participant.ActorType
|
||||||
import com.nextcloud.talk.models.json.signaling.NCSignalingMessage
|
import com.nextcloud.talk.models.json.signaling.NCSignalingMessage
|
||||||
|
import com.nextcloud.talk.models.json.signaling.settings.FederationSettings
|
||||||
import com.nextcloud.talk.models.json.websocket.BaseWebSocketMessage
|
import com.nextcloud.talk.models.json.websocket.BaseWebSocketMessage
|
||||||
import com.nextcloud.talk.models.json.websocket.ByeWebSocketMessage
|
import com.nextcloud.talk.models.json.websocket.ByeWebSocketMessage
|
||||||
import com.nextcloud.talk.models.json.websocket.CallOverallWebSocketMessage
|
import com.nextcloud.talk.models.json.websocket.CallOverallWebSocketMessage
|
||||||
@ -75,6 +76,7 @@ class WebSocketInstance internal constructor(
|
|||||||
private val connectionUrl: String
|
private val connectionUrl: String
|
||||||
private var currentRoomToken: String? = null
|
private var currentRoomToken: String? = null
|
||||||
private var currentNormalBackendSession: String? = null
|
private var currentNormalBackendSession: String? = null
|
||||||
|
private var currentFederation: FederationSettings? = null
|
||||||
private var reconnecting = false
|
private var reconnecting = false
|
||||||
private val usersHashMap: HashMap<String?, Participant>
|
private val usersHashMap: HashMap<String?, Participant>
|
||||||
private var messagesQueue: MutableList<String> = ArrayList()
|
private var messagesQueue: MutableList<String> = ArrayList()
|
||||||
@ -367,24 +369,28 @@ class WebSocketInstance internal constructor(
|
|||||||
return hasMCU
|
return hasMCU
|
||||||
}
|
}
|
||||||
|
|
||||||
fun joinRoomWithRoomTokenAndSession(roomToken: String, normalBackendSession: String?) {
|
fun joinRoomWithRoomTokenAndSession(roomToken: String, normalBackendSession: String?,
|
||||||
|
federation: FederationSettings? = null) {
|
||||||
Log.d(TAG, "joinRoomWithRoomTokenAndSession")
|
Log.d(TAG, "joinRoomWithRoomTokenAndSession")
|
||||||
Log.d(TAG, " roomToken: $roomToken")
|
Log.d(TAG, " roomToken: $roomToken")
|
||||||
Log.d(TAG, " session: $normalBackendSession")
|
Log.d(TAG, " session: $normalBackendSession")
|
||||||
try {
|
try {
|
||||||
val message = LoganSquare.serialize(
|
val message = LoganSquare.serialize(
|
||||||
webSocketConnectionHelper.getAssembledJoinOrLeaveRoomModel(roomToken, normalBackendSession)
|
webSocketConnectionHelper.getAssembledJoinOrLeaveRoomModel(roomToken, normalBackendSession, federation)
|
||||||
)
|
)
|
||||||
if (roomToken == "") {
|
if (roomToken == "") {
|
||||||
Log.d(TAG, "sending 'leave room' via websocket")
|
Log.d(TAG, "sending 'leave room' via websocket")
|
||||||
currentNormalBackendSession = ""
|
currentNormalBackendSession = ""
|
||||||
|
currentFederation = null
|
||||||
sendMessage(message)
|
sendMessage(message)
|
||||||
} else if (roomToken == currentRoomToken && normalBackendSession == currentNormalBackendSession) {
|
} else if (roomToken == currentRoomToken && normalBackendSession == currentNormalBackendSession &&
|
||||||
|
federation == currentFederation) {
|
||||||
Log.d(TAG, "roomToken & session are unchanged. Joining locally without to send websocket message")
|
Log.d(TAG, "roomToken & session are unchanged. Joining locally without to send websocket message")
|
||||||
sendRoomJoinedEvent()
|
sendRoomJoinedEvent()
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "Sending join room message via websocket")
|
Log.d(TAG, "Sending join room message via websocket")
|
||||||
currentNormalBackendSession = normalBackendSession
|
currentNormalBackendSession = normalBackendSession
|
||||||
|
currentFederation = federation
|
||||||
sendMessage(message)
|
sendMessage(message)
|
||||||
}
|
}
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
|
Loading…
Reference in New Issue
Block a user