openvidu-android: Fixed crash leaving session
This commit is contained in:
parent
e362117f35
commit
8bb8321490
@ -1,5 +1,6 @@
|
||||
package io.openvidu.openvidu_android.openvidu;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
@ -195,22 +196,28 @@ public class Session {
|
||||
}
|
||||
|
||||
public void leaveSession() {
|
||||
websocket.setWebsocketCancelled(true);
|
||||
if (websocket != null) {
|
||||
websocket.leaveRoom();
|
||||
websocket.disconnect();
|
||||
}
|
||||
this.localParticipant.dispose();
|
||||
for (RemoteParticipant remoteParticipant : remoteParticipants.values()) {
|
||||
if (remoteParticipant.getPeerConnection() != null) {
|
||||
remoteParticipant.getPeerConnection().close();
|
||||
AsyncTask.execute(() -> {
|
||||
websocket.setWebsocketCancelled(true);
|
||||
if (websocket != null) {
|
||||
websocket.leaveRoom();
|
||||
websocket.disconnect();
|
||||
}
|
||||
views_container.removeView(remoteParticipant.getView());
|
||||
}
|
||||
if (peerConnectionFactory != null) {
|
||||
peerConnectionFactory.dispose();
|
||||
peerConnectionFactory = null;
|
||||
}
|
||||
this.localParticipant.dispose();
|
||||
});
|
||||
this.activity.runOnUiThread(() -> {
|
||||
for (RemoteParticipant remoteParticipant : remoteParticipants.values()) {
|
||||
if (remoteParticipant.getPeerConnection() != null) {
|
||||
remoteParticipant.getPeerConnection().close();
|
||||
}
|
||||
views_container.removeView(remoteParticipant.getView());
|
||||
}
|
||||
});
|
||||
AsyncTask.execute(() -> {
|
||||
if (peerConnectionFactory != null) {
|
||||
peerConnectionFactory.dispose();
|
||||
peerConnectionFactory = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void removeView(View view) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<resources>
|
||||
<string name="app_name">WebRTCExampleApp</string>
|
||||
<string name="app_name">OpenVidu Android Sample</string>
|
||||
<string name="start_button">Join</string>
|
||||
<string name="session_name">Session Name</string>
|
||||
<string name="default_session_name">SessionA</string>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user