mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 14:27:24 +00:00
Get user ID from signaling message when creating ParticipantDisplayItem
The user ID set when creating the ParticipantDisplayItem was got from the join event when the external signaling server was used, and from an API call when the internal signaling server was used. However, the user ID is already known from the signaling message that updates the participant list, and is the one set on the ParticipantDisplayItems when a participant joins the call. Therefore the other sources are not needed, so now it is unified to always use the value from the signaling message. Note that in the rare cases in which a ParticipantDisplayItem is created before the participant is seen as in the call the user ID will be temporary unknown, although it will be automatically fixed once the participant list update is received. Moreover, even if the other sources were used it was not guaranteed that the user ID was known, so this should not be a problem. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
parent
6e222e7cd2
commit
29117e8b1b
@ -74,7 +74,6 @@ import com.nextcloud.talk.models.json.conversations.RoomOverall;
|
|||||||
import com.nextcloud.talk.models.json.conversations.RoomsOverall;
|
import com.nextcloud.talk.models.json.conversations.RoomsOverall;
|
||||||
import com.nextcloud.talk.models.json.generic.GenericOverall;
|
import com.nextcloud.talk.models.json.generic.GenericOverall;
|
||||||
import com.nextcloud.talk.models.json.participants.Participant;
|
import com.nextcloud.talk.models.json.participants.Participant;
|
||||||
import com.nextcloud.talk.models.json.participants.ParticipantsOverall;
|
|
||||||
import com.nextcloud.talk.models.json.signaling.DataChannelMessage;
|
import com.nextcloud.talk.models.json.signaling.DataChannelMessage;
|
||||||
import com.nextcloud.talk.models.json.signaling.NCMessagePayload;
|
import com.nextcloud.talk.models.json.signaling.NCMessagePayload;
|
||||||
import com.nextcloud.talk.models.json.signaling.NCSignalingMessage;
|
import com.nextcloud.talk.models.json.signaling.NCSignalingMessage;
|
||||||
@ -236,7 +235,7 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
private MediaStream localStream;
|
private MediaStream localStream;
|
||||||
private String credentials;
|
private String credentials;
|
||||||
private List<PeerConnectionWrapper> peerConnectionWrapperList = new ArrayList<>();
|
private List<PeerConnectionWrapper> peerConnectionWrapperList = new ArrayList<>();
|
||||||
private Map<String, Participant> participantMap = new HashMap<>();
|
private Map<String, String> userIdsBySessionId = new HashMap<>();
|
||||||
|
|
||||||
private boolean videoOn = false;
|
private boolean videoOn = false;
|
||||||
private boolean microphoneOn = false;
|
private boolean microphoneOn = false;
|
||||||
@ -1775,7 +1774,7 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
Log.d(TAG, "processUsersInRoom");
|
Log.d(TAG, "processUsersInRoom");
|
||||||
List<String> newSessions = new ArrayList<>();
|
List<String> newSessions = new ArrayList<>();
|
||||||
Set<String> oldSessions = new HashSet<>();
|
Set<String> oldSessions = new HashSet<>();
|
||||||
Map<String, String> userIdsBySessionId = new HashMap<>();
|
userIdsBySessionId = new HashMap<>();
|
||||||
|
|
||||||
hasMCU = hasExternalSignalingServer && webSocketClient != null && webSocketClient.hasMCU();
|
hasMCU = hasExternalSignalingServer && webSocketClient != null && webSocketClient.hasMCU();
|
||||||
Log.d(TAG, " hasMCU is " + hasMCU);
|
Log.d(TAG, " hasMCU is " + hasMCU);
|
||||||
@ -1844,10 +1843,6 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newSessions.size() > 0 && !hasMCU) {
|
|
||||||
getPeersForCall();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasMCU) {
|
if (hasMCU) {
|
||||||
// Ensure that own publishing peer is set up.
|
// Ensure that own publishing peer is set up.
|
||||||
getOrCreatePeerConnectionWrapperForSessionIdAndType(webSocketClient.getSessionId(), VIDEO_STREAM_TYPE_VIDEO, true);
|
getOrCreatePeerConnectionWrapperForSessionIdAndType(webSocketClient.getSessionId(), VIDEO_STREAM_TYPE_VIDEO, true);
|
||||||
@ -1886,43 +1881,6 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getPeersForCall() {
|
|
||||||
Log.d(TAG, "getPeersForCall");
|
|
||||||
int apiVersion = ApiUtils.getCallApiVersion(conversationUser, new int[]{ApiUtils.APIv4, 1});
|
|
||||||
|
|
||||||
ncApi.getPeersForCall(
|
|
||||||
credentials,
|
|
||||||
ApiUtils.getUrlForCall(
|
|
||||||
apiVersion,
|
|
||||||
baseUrl,
|
|
||||||
roomToken))
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.subscribe(new Observer<ParticipantsOverall>() {
|
|
||||||
@Override
|
|
||||||
public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) {
|
|
||||||
// unused atm
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNext(@io.reactivex.annotations.NonNull ParticipantsOverall participantsOverall) {
|
|
||||||
participantMap = new HashMap<>();
|
|
||||||
for (Participant participant : participantsOverall.getOcs().getData()) {
|
|
||||||
participantMap.put(participant.getSessionId(), participant);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(@io.reactivex.annotations.NonNull Throwable e) {
|
|
||||||
Log.e(TAG, "error while executing getPeersForCall", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
// unused atm
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void deletePeerConnection(PeerConnectionWrapper peerConnectionWrapper) {
|
private void deletePeerConnection(PeerConnectionWrapper peerConnectionWrapper) {
|
||||||
peerConnectionWrapper.removePeerConnection();
|
peerConnectionWrapper.removePeerConnection();
|
||||||
peerConnectionWrapperList.remove(peerConnectionWrapper);
|
peerConnectionWrapperList.remove(peerConnectionWrapper);
|
||||||
@ -2291,12 +2249,7 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
nick = offerAnswerNickProviders.get(session) != null ? offerAnswerNickProviders.get(session).getNick() : "";
|
nick = offerAnswerNickProviders.get(session) != null ? offerAnswerNickProviders.get(session).getNick() : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
String userId = null;
|
String userId = userIdsBySessionId.get(session);
|
||||||
if (hasMCU) {
|
|
||||||
userId = webSocketClient.getUserIdForSession(session);
|
|
||||||
} else if (participantMap.get(session) != null && participantMap.get(session).getCalculatedActorType() == Participant.ActorType.USERS) {
|
|
||||||
userId = participantMap.get(session).getCalculatedActorId();
|
|
||||||
}
|
|
||||||
|
|
||||||
String defaultGuestNick = getResources().getString(R.string.nc_nick_guest);
|
String defaultGuestNick = getResources().getString(R.string.nc_nick_guest);
|
||||||
|
|
||||||
|
@ -386,17 +386,6 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserIdForSession(String session) {
|
|
||||||
Participant participant = usersHashMap.get(session);
|
|
||||||
if (participant != null) {
|
|
||||||
if (participant.getCalculatedActorType() == USERS) {
|
|
||||||
return participant.getCalculatedActorId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.BACKGROUND)
|
@Subscribe(threadMode = ThreadMode.BACKGROUND)
|
||||||
public void onMessageEvent(NetworkEvent networkEvent) {
|
public void onMessageEvent(NetworkEvent networkEvent) {
|
||||||
if (networkEvent.getNetworkConnectionEvent() == NetworkEvent.NetworkConnectionEvent.NETWORK_CONNECTED && !isConnected()) {
|
if (networkEvent.getNetworkConnectionEvent() == NetworkEvent.NetworkConnectionEvent.NETWORK_CONNECTED && !isConnected()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user