mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 14:27:24 +00:00
Extract methods to handle connections and disconnections of peers
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
parent
4457e92504
commit
337f3d4b5e
@ -2117,24 +2117,13 @@ public class CallActivity extends CallBaseActivity {
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMessageEvent(PeerConnectionEvent peerConnectionEvent) {
|
||||
String sessionId = peerConnectionEvent.getSessionId();
|
||||
String participantDisplayItemId = sessionId + "-" + peerConnectionEvent.getVideoStreamType();
|
||||
|
||||
if (peerConnectionEvent.getPeerConnectionEventType() ==
|
||||
PeerConnectionEvent.PeerConnectionEventType.PEER_CONNECTED) {
|
||||
if (webSocketClient != null && webSocketClient.getSessionId() != null && webSocketClient.getSessionId().equals(sessionId)) {
|
||||
updateSelfVideoViewConnected(true);
|
||||
} else if (participantDisplayItems.get(participantDisplayItemId) != null) {
|
||||
participantDisplayItems.get(participantDisplayItemId).setConnected(true);
|
||||
participantsAdapter.notifyDataSetChanged();
|
||||
}
|
||||
handlePeerConnected(sessionId, peerConnectionEvent.getVideoStreamType());
|
||||
} else if (peerConnectionEvent.getPeerConnectionEventType() ==
|
||||
PeerConnectionEvent.PeerConnectionEventType.PEER_DISCONNECTED) {
|
||||
if (webSocketClient != null && webSocketClient.getSessionId() != null && webSocketClient.getSessionId().equals(sessionId)) {
|
||||
updateSelfVideoViewConnected(false);
|
||||
} else if (participantDisplayItems.get(participantDisplayItemId) != null) {
|
||||
participantDisplayItems.get(participantDisplayItemId).setConnected(false);
|
||||
participantsAdapter.notifyDataSetChanged();
|
||||
}
|
||||
handlePeerDisconnected(sessionId, peerConnectionEvent.getVideoStreamType());
|
||||
} else if (peerConnectionEvent.getPeerConnectionEventType() ==
|
||||
PeerConnectionEvent.PeerConnectionEventType.PEER_CLOSED) {
|
||||
endPeerConnection(sessionId, VIDEO_STREAM_TYPE_SCREEN.equals(peerConnectionEvent.getVideoStreamType()));
|
||||
@ -2162,6 +2151,28 @@ public class CallActivity extends CallBaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private void handlePeerConnected(String sessionId, String videoStreamType) {
|
||||
String participantDisplayItemId = sessionId + "-" + videoStreamType;
|
||||
|
||||
if (webSocketClient != null && webSocketClient.getSessionId() != null && webSocketClient.getSessionId().equals(sessionId)) {
|
||||
updateSelfVideoViewConnected(true);
|
||||
} else if (participantDisplayItems.get(participantDisplayItemId) != null) {
|
||||
participantDisplayItems.get(participantDisplayItemId).setConnected(true);
|
||||
participantsAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void handlePeerDisconnected(String sessionId, String videoStreamType) {
|
||||
String participantDisplayItemId = sessionId + "-" + videoStreamType;
|
||||
|
||||
if (webSocketClient != null && webSocketClient.getSessionId() != null && webSocketClient.getSessionId().equals(sessionId)) {
|
||||
updateSelfVideoViewConnected(false);
|
||||
} else if (participantDisplayItems.get(participantDisplayItemId) != null) {
|
||||
participantDisplayItems.get(participantDisplayItemId).setConnected(false);
|
||||
participantsAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void startSendingNick() {
|
||||
DataChannelMessage dataChannelMessage = new DataChannelMessage();
|
||||
dataChannelMessage.setType("nickChanged");
|
||||
|
Loading…
Reference in New Issue
Block a user