Skip to content
This repository was archived by the owner on Nov 19, 2020. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions android/src/main/java/com/rnopentok/RNOpenTokSubscriberView.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ private void attachSubscriberView() {
}

private void cleanUpSubscriber() {
removeView(mSubscriber.getView());
mSubscriber = null;
if ( mSubscriber != null ) {
removeView(mSubscriber.getView());
mSubscriber.destroy();
mSubscriber = null;
}
}

public void onStreamReceived(Session session, Stream stream) {
Expand All @@ -89,14 +92,18 @@ public void onStreamDropped(Session session, Stream stream) {
public void onConnected(SubscriberKit subscriberKit) {}

@Override
public void onDisconnected(SubscriberKit subscriberKit) {}
public void onDisconnected(SubscriberKit subscriberKit) {
cleanUpSubscriber();
}

@Override
public void onError(SubscriberKit subscriberKit, OpentokError opentokError) {
WritableMap payload = Arguments.createMap();
payload.putString("connectionId", opentokError.toString());

sendEvent(Events.EVENT_SUBSCRIBE_ERROR, payload);

cleanUpSubscriber();
}

}