Skip to content
This repository was archived by the owner on Mar 9, 2021. It is now read-only.

Commit bc7510e

Browse files
author
Sean Perkins
committed
Move unsubscribe logic to subscriber class
1 parent 8619763 commit bc7510e

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

demo/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"nativescript": {
33
"id": "com.mobileagility.opentok",
4-
"tns-android": {
5-
"version": "2.4.1"
6-
},
74
"tns-ios": {
85
"version": "2.4.0"
6+
},
7+
"tns-android": {
8+
"version": "2.4.1"
99
}
1010
},
1111
"dependencies": {
@@ -23,4 +23,4 @@
2323
"tns-platform-declarations": "^2.4.0",
2424
"typescript": "^2.0.7"
2525
}
26-
}
26+
}

src/android/session.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -230,17 +230,6 @@ export class TNSOTSession {
230230
this.session.subscribe(subInstance);
231231
}
232232

233-
public unsubscribe(): Promise<any> {
234-
return new Promise((resolve, reject) => {
235-
try {
236-
this.session.unsubscribe(this.subscriber);
237-
resolve();
238-
} catch (err) {
239-
reject(err);
240-
}
241-
});
242-
}
243-
244233
get sessionEvents(): Observable {
245234
return this._sessionEvents;
246235
}

src/android/subscriber.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Observable} from "data/observable";
22
import {ContentView} from 'ui/content-view';
3+
import {TNSOTSession} from "./session";
34
declare var com: any, android: any;
45
const StreamListener = com.opentok.android.SubscriberKit.StreamListener;
56
const SubscriberListener = com.opentok.android.SubscriberKit.SubscriberListener;
@@ -111,5 +112,11 @@ export class TNSOTSubscriber extends ContentView {
111112
this._subscriber.setSubscribeToAudio(state);
112113
}
113114

115+
unsubscribe(session: TNSOTSession) {
116+
if(this._subscriber) {
117+
session.session.unsubscribe(this._subscriber);
118+
}
119+
}
120+
114121

115122
}

0 commit comments

Comments
 (0)