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

Commit

Permalink
Merge pull request #23 from sean-perkins/release-1.5.12
Browse files Browse the repository at this point in the history
Release 1.5.12
  • Loading branch information
Sean Perkins authored Sep 14, 2016
2 parents 2893a05 + f444a27 commit 56771bc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 29 deletions.
1 change: 1 addition & 0 deletions demo/app/main-page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<Button text="Switch Camera" tap="{{ switchCamera }}" />
<Button text="Toggle Camera" tap="{{ toggleVideo }}" />
<Button text="Toggle Mute" tap="{{ toggleMute }}" />
<Button text="Start Publishing" tap="{{ publish }}" />
<Button text="Stop Publishing" tap="{{ unpublish }}" />
<Button text="Stop Subscribing" tap="{{ unsubscribe }}" />
<Button text="Disconnect" tap="{{ disconnect }}" />
Expand Down
14 changes: 2 additions & 12 deletions demo/app/main-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,12 @@ export class Demo extends Observable {
this.session = TNSOTSession.initWithApiKeySessionId(this._apiKey, this._sessionId);
this.publisher = <TNSOTPublisher> this.page.getViewById('publisher');
this.subscriber = <TNSOTSubscriber> this.page.getViewById('subscriber');
this.initPublisher();
this.initSubscriber();
this.session.subscriber = this.subscriber;
}

initPublisher() {
publish() {
this.session.connect(this._publisherToken);
this.publisher.publish(this.session, '', 'HIGH', '30');
this.publisher.events.on('streamDestroyed', (result) => {
console.log('publisher stream destroyed');
});
}

initSubscriber() {
this.session.events.on('streamCreated', () => {
this.subscriber.subscribe(this.session);
});
}

switchCamera() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-opentok",
"version": "1.5.11",
"version": "1.5.12",
"description": "Integrates OpenTok for NativeScript.",
"main": "opentok.js",
"typings": "./opentok.d.ts",
Expand Down
14 changes: 8 additions & 6 deletions src/ios/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export class TNSOTSession extends NSObject {

public _ios: any;

private _stream: any;
private _events: Observable;
private _subscriber: TNSOTSubscriber;

public static initWithApiKeySessionId(apiKey: string, sessionId: string): TNSOTSession {
let instance = <TNSOTSession>TNSOTSession.new();
Expand Down Expand Up @@ -61,12 +61,12 @@ export class TNSOTSession extends NSObject {
}
}

get events(): Observable {
return this._events;
set subscriber(subscriber) {
this._subscriber = subscriber;
}

get stream(): any {
return this._stream;
get events(): Observable {
return this._events;
}

public sessionDidConnect(session: any) {
Expand Down Expand Up @@ -115,7 +115,9 @@ export class TNSOTSession extends NSObject {
})
});
}
this._stream = stream;
if(this._subscriber) {
this._subscriber.subscribe(session, stream);
}
}

public sessionStreamDestroyed(session: any, stream: any) {
Expand Down
18 changes: 8 additions & 10 deletions src/ios/subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@ export class TNSOTSubscriber extends ContentView {
this._view = UIView.alloc().init();
}

subscribe(session: any) {
if(session.stream) {
this._ios = new OTSubscriber(session.stream, this._subscriberKitDelegate);
this._ios.view.frame = CGRectMake(0, 0, screen.mainScreen.widthDIPs, screen.mainScreen.heightDIPs);
this._view.addSubview(this._ios.view);
let errorRef = new interop.Reference();
session._ios.subscribeError(this._ios, errorRef);
if(errorRef.value) {
console.log(errorRef.value);
}
subscribe(session: any, stream: any) {
this._ios = new OTSubscriber(stream, this._subscriberKitDelegate);
this._ios.view.frame = CGRectMake(0, 0, screen.mainScreen.widthDIPs, screen.mainScreen.heightDIPs);
this._view.addSubview(this._ios.view);
let errorRef = new interop.Reference();
session.subscribeError(this._ios, errorRef);
if(errorRef.value) {
console.log(errorRef.value);
}
}

Expand Down

0 comments on commit 56771bc

Please sign in to comment.