Always pass the session id in "NICK_CHANGE" PeerConnectionEvents

Before the NICK_CHANGE event include either the session id or the user
id, depending on whether the participant was a guest or a user. However,
as the session id is also known for users the event can be unified to
always include the session id only.

This also fixes an exception when handling the "NICK_CHANGE" event, as
the session id was got from the user id given in the event, but if the
event already included the session id the look up failed and the session
id was replaced with an empty value. This in turn caused an exception
when trying to use the view for the now invalid session id. Now the
session id provided in the event is always directly used.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2020-10-01 19:07:25 +02:00
parent 5b9f02e99c
commit 6b2720653a
2 changed files with 4 additions and 9 deletions

View file

@ -2031,16 +2031,11 @@ public class CallController extends BaseController {
}
}
private void gotNick(String sessionOrUserId, String nick, boolean isFromAnEvent, String type) {
if (isFromAnEvent && hasExternalSignalingServer) {
// get session based on userId
sessionOrUserId = webSocketClient.getSessionForUserId(sessionOrUserId);
}
sessionOrUserId += "+" + type;
private void gotNick(String sessionId, String nick, boolean isFromAnEvent, String type) {
sessionId += "+" + type;
if (relativeLayout != null) {
RelativeLayout relativeLayout = remoteRenderersLayout.findViewWithTag(sessionOrUserId);
RelativeLayout relativeLayout = remoteRenderersLayout.findViewWithTag(sessionId);
TextView textView = relativeLayout.findViewById(R.id.peer_nick_text_view);
if (!textView.getText().equals(nick)) {
textView.setText(nick);

View file

@ -279,7 +279,7 @@ public class MagicPeerConnectionWrapper {
if (dataChannelMessage.getPayload() != null) {
HashMap<String, String> payloadHashMap = (HashMap<String, String>) dataChannelMessage.getPayload();
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
.NICK_CHANGE, payloadHashMap.get("userid"), payloadHashMap.get("name"), null, videoStreamType));
.NICK_CHANGE, sessionId, payloadHashMap.get("name"), null, videoStreamType));
}
}