Skip to content

Commit 2c2e354

Browse files
authored
Merge branch 'master' into master
2 parents 6b3f0aa + d21ce14 commit 2c2e354

File tree

22 files changed

+150
-103
lines changed

22 files changed

+150
-103
lines changed

.travis.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
dist: trusty
2+
sudo: required
13
language: php
2-
php:
3-
- '5.6'
4-
- '5.5'
5-
- '5.4'
6-
- '5.3'
7-
- 'hhvm'
4+
matrix:
5+
include:
6+
- php: 5.3
7+
dist: precise
8+
- php: 5.4
9+
- php: 5.5
10+
- php: 5.6
11+
- php: hhvm
812
before_script:
913
- travis_retry composer install
1014
script:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Add this package (`opentok/opentok`) to your `composer.json` file, or just run t
1616
command line:
1717

1818
```
19-
$ ./composer.phar require opentok/opentok 2.4.x
19+
$ ./composer.phar require opentok/opentok 2.5.x
2020
```
2121

2222
## Manually:

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
"php": ">=5.0.0",
3232
"guzzle/guzzle": "~3.7",
3333
"aoberoi/json-works": "~1.0",
34-
"firebase/php-jwt": "^3.0"
34+
"firebase/php-jwt": "^4.0"
3535
},
3636
"require-dev": {
3737
"phpunit/phpunit": "~4.1",
38-
"phing/phing": "dev-master"
38+
"phing/phing": "~2.15.2"
3939
},
4040
"autoload": {
4141
"psr-4": {

sample/Archiving/web/js/host.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
1-
var session = OT.initSession(sessionId),
1+
var session = OT.initSession(apiKey, sessionId),
22
publisher = OT.initPublisher('publisher'),
33
archiveID = null;
44

5-
session.connect(apiKey, token, function(error) {
6-
if(error) {
7-
console.error(error.message);
8-
return;
5+
session.connect(token, function(error) {
6+
if (error) {
7+
console.error('Failed to connect', error);
8+
} else {
9+
session.publish(publisher, function(error) {
10+
if (error) {
11+
console.error('Failed to publish', error);
12+
}
13+
});
914
}
10-
session.publish(publisher);
1115
});
1216

1317
session.on('streamCreated', function(event) {
14-
session.subscribe(event.stream, 'subscribers', { insertMode: 'append' });
18+
session.subscribe(event.stream, 'subscribers', {
19+
insertMode: 'append'
20+
}, function(error) {
21+
if (error) {
22+
console.error('Failed to subscribe', error);
23+
}
24+
});
1525
});
1626

1727
session.on('archiveStarted', function(event) {
@@ -31,7 +41,7 @@ session.on('archiveStopped', function(event) {
3141
});
3242

3343
$(document).ready(function() {
34-
$('.start').click(function (event) {
44+
$('.start').click(function(event) {
3545
var options = $('.archive-options').serialize();
3646
disableForm();
3747
$.post('/start', options).fail(enableForm);
Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1-
var session = OT.initSession(sessionId),
1+
var session = OT.initSession(apiKey, sessionId),
22
publisher = OT.initPublisher('publisher');
33

4-
session.connect(apiKey, token, function(error) {
5-
if(error) {
6-
console.error(error.message);
7-
return;
4+
session.connect(token, function(error) {
5+
if (error) {
6+
console.error('Failed to connect', error);
7+
} else {
8+
session.publish(publisher, function(error) {
9+
if (error) {
10+
console.error('Failed to publish', error);
11+
}
12+
});
813
}
9-
session.publish(publisher);
1014
});
1115

1216
session.on('streamCreated', function(event) {
13-
session.subscribe(event.stream, 'subscribers', { insertMode : 'append' });
17+
session.subscribe(event.stream, 'subscribers', {
18+
insertMode : 'append'
19+
}, function(error) {
20+
if (error) {
21+
console.error('Failed to subscribe', error);
22+
}
23+
});
1424
});
Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
// Initialize an OpenTok Session object.
2-
var session = OT.initSession(sessionId);
2+
var session = OT.initSession(apiKey, sessionId);
33

44
// Initialize a Publisher, and place it into the 'publisher' DOM element.
5-
var publisher = OT.initPublisher(apiKey, 'publisher');
5+
var publisher = OT.initPublisher('publisher');
66

77
session.on('streamCreated', function(event) {
88
// Called when another client publishes a stream.
99
// Subscribe to the stream that caused this event.
10-
session.subscribe(event.stream, 'subscribers', { insertMode: 'append' });
10+
session.subscribe(event.stream, 'subscribers', {
11+
insertMode: 'append'
12+
}, function(error) {
13+
if (error) {
14+
console.error('Failed to subscribe', error);
15+
}
16+
});
1117
});
1218

1319
// Connect to the session using your OpenTok API key and the client's token for the session
14-
session.connect(apiKey, token, function(error) {
20+
session.connect(token, function(error) {
1521
if (error) {
16-
console.error(error);
22+
console.error('Failed to connect', error);
1723
} else {
1824
// Publish a stream, using the Publisher we initialzed earlier.
1925
// This triggers a streamCreated event on other clients.
20-
session.publish(publisher);
26+
session.publish(publisher, function(error) {
27+
if (error) {
28+
console.error('Failed to publish', error);
29+
}
30+
});
2131
}
2232
});

sample/SipCall/templates/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<link rel='stylesheet' href='/stylesheets/style.css' />
77
<link rel='stylesheet' href='/stylesheets/pattern.css' />
88
<script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
9-
<script src="https://static.opentok.com/v2/js/opentok.js"></script>
9+
<script src="https://static.opentok.com/v2/js/opentok.min.js"></script>
1010
<script>
1111
var sessionId = "<?php echo $sessionId ?>";
1212
var token = "<?php echo $token ?>";

sample/SipCall/web/js/index.js

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,44 @@
1-
var session = OT.initSession(sessionId);
2-
session.on("streamCreated", function (event) {
1+
var session = OT.initSession(apiKey, sessionId);
2+
session.on('streamCreated', function(event) {
33
var tokenData = event.stream.connection.data;
4-
if (tokenData && tokenData.includes("sip=true")) {
5-
var element = "sipPublisherContainer";
4+
if (tokenData && tokenData.includes('sip=true')) {
5+
var element = 'sipPublisherContainer';
66
} else {
7-
var element = "webrtcPublisherContainer";
7+
var element = 'webrtcPublisherContainer';
88
}
9-
session.subscribe(event.stream, element, { insertMode: "append" });
9+
session.subscribe(event.stream, element, {
10+
insertMode: 'append'
11+
}, function(error) {
12+
if (error) {
13+
console.error('Failed to subscribe', error);
14+
}
15+
});
1016
})
11-
.connect(apiKey, token, function (err) {
12-
if (err) return;
13-
session.publish("selfPublisherContainer", {
14-
insertMode: "append",
15-
height: "120px",
16-
width: "160px"
17+
.connect(token, function(error) {
18+
if (error) {
19+
console.error('Failed to connect', error);
20+
return;
21+
}
22+
session.publish('selfPublisherContainer', {
23+
insertMode: 'append',
24+
height: '120px',
25+
width: '160px'
26+
}, function(error) {
27+
if (error) {
28+
console.error('Failed to publish', error);
29+
}
1730
});
1831
});
19-
$('#startSip').click(function (event) {
32+
$('#startSip').click(function(event) {
2033
$.post('/sip/start', {sessionId: sessionId, apiKey: apiKey})
21-
.fail(function () {
34+
.fail(function() {
2235
console.log('Failed to start SIP call - sample app server returned error.');
2336
});
2437
});
25-
$('#stopSip').click(function (event) {
26-
OT.subscribers.where().forEach(function (subscriber) {
38+
$('#stopSip').click(function(event) {
39+
OT.subscribers.where().forEach(function(subscriber) {
2740
var connection = subscriber.stream.connection;
28-
if (connection.data && connection.data.includes("sip=true")) {
41+
if (connection.data && connection.data.includes('sip=true')) {
2942
session.forceDisconnect(connection.connectionId);
3043
}
3144
});

src/OpenTok/Util/Client.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
// TODO: build this dynamically
2525
/** @internal */
26-
define('OPENTOK_SDK_VERSION', '2.4.1-alpha.1');
26+
define('OPENTOK_SDK_VERSION', '2.5.0');
2727
/** @internal */
2828
define('OPENTOK_SDK_USER_AGENT', 'OpenTok-PHP-SDK/' . OPENTOK_SDK_VERSION);
2929

@@ -79,7 +79,7 @@ public function createSession($options)
7979
public function startArchive($sessionId, $options)
8080
{
8181
// set up the request
82-
$request = $this->post('/v2/partner/'.$this->apiKey.'/archive');
82+
$request = $this->post('/v2/project/'.$this->apiKey.'/archive');
8383
$request->setBody(json_encode(array_merge(array( 'sessionId' => $sessionId ), $options)));
8484
$request->setHeader('Content-Type', 'application/json');
8585

@@ -94,7 +94,7 @@ public function startArchive($sessionId, $options)
9494
public function stopArchive($archiveId)
9595
{
9696
// set up the request
97-
$request = $this->post('/v2/partner/'.$this->apiKey.'/archive/'.$archiveId.'/stop');
97+
$request = $this->post('/v2/project/'.$this->apiKey.'/archive/'.$archiveId.'/stop');
9898
$request->setHeader('Content-Type', 'application/json');
9999

100100
try {
@@ -108,7 +108,7 @@ public function stopArchive($archiveId)
108108

109109
public function getArchive($archiveId)
110110
{
111-
$request = $this->get('/v2/partner/'.$this->apiKey.'/archive/'.$archiveId);
111+
$request = $this->get('/v2/project/'.$this->apiKey.'/archive/'.$archiveId);
112112
try {
113113
$archiveJson = $request->send()->json();
114114
} catch (\Exception $e) {
@@ -120,7 +120,7 @@ public function getArchive($archiveId)
120120

121121
public function deleteArchive($archiveId)
122122
{
123-
$request = $this->delete('/v2/partner/'.$this->apiKey.'/archive/'.$archiveId);
123+
$request = $this->delete('/v2/project/'.$this->apiKey.'/archive/'.$archiveId);
124124
$request->setHeader('Content-Type', 'application/json');
125125
try {
126126
$request->send()->json();
@@ -133,7 +133,7 @@ public function deleteArchive($archiveId)
133133

134134
public function listArchives($offset, $count)
135135
{
136-
$request = $this->get('/v2/partner/'.$this->apiKey.'/archive');
136+
$request = $this->get('/v2/project/'.$this->apiKey.'/archive');
137137
if ($offset != 0) $request->getQuery()->set('offset', $offset);
138138
if (!empty($count)) $request->getQuery()->set('count', $count);
139139
try {
@@ -242,7 +242,7 @@ public function dial($sessionId, $token, $sipUri, $options)
242242
}
243243

244244
// set up the request
245-
$request = $this->post('/v2/partner/'.$this->apiKey.'/call');
245+
$request = $this->post('/v2/project/'.$this->apiKey.'/call');
246246
$request->setBody(json_encode($body));
247247
$request->setHeader('Content-Type', 'application/json');
248248

tests/OpenTok/ArchiveTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function testStopsArchive()
8484
// Arrange
8585
$mock = new MockPlugin();
8686
$response = MockPlugin::getMockFile(
87-
self::$mockBasePath . 'v2/partner/APIKEY/archive/ARCHIVEID/stop'
87+
self::$mockBasePath . 'v2/project/APIKEY/archive/ARCHIVEID/stop'
8888
);
8989
$mock->addResponse($response);
9090
$this->client->addSubscriber($mock);
@@ -98,7 +98,7 @@ public function testStopsArchive()
9898

9999
$request = $requests[0];
100100
$this->assertEquals('POST', strtoupper($request->getMethod()));
101-
$this->assertEquals('/v2/partner/'.$this->API_KEY.'/archive/'.$this->archiveData['id'].'/stop', $request->getPath());
101+
$this->assertEquals('/v2/project/'.$this->API_KEY.'/archive/'.$this->archiveData['id'].'/stop', $request->getPath());
102102
$this->assertEquals('api.opentok.com', $request->getHost());
103103
$this->assertEquals('https', $request->getScheme());
104104

@@ -112,7 +112,7 @@ public function testStopsArchive()
112112
// TODO: test the dynamically built User Agent string
113113
$userAgent = $request->getHeader('User-Agent');
114114
$this->assertNotEmpty($userAgent);
115-
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.4.1-alpha.1', $userAgent->__toString());
115+
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
116116

117117
// TODO: test the properties of the actual archive object
118118
$this->assertEquals('stopped', $this->archive->status);
@@ -124,7 +124,7 @@ public function testDeletesArchive()
124124
// Arrange
125125
$mock = new MockPlugin();
126126
$response = MockPlugin::getMockFile(
127-
self::$mockBasePath . 'v2/partner/APIKEY/archive/ARCHIVEID/delete'
127+
self::$mockBasePath . 'v2/project/APIKEY/archive/ARCHIVEID/delete'
128128
);
129129
$mock->addResponse($response);
130130
$this->client->addSubscriber($mock);
@@ -140,7 +140,7 @@ public function testDeletesArchive()
140140

141141
$request = $requests[0];
142142
$this->assertEquals('DELETE', strtoupper($request->getMethod()));
143-
$this->assertEquals('/v2/partner/'.$this->API_KEY.'/archive/'.$this->archiveData['id'], $request->getPath());
143+
$this->assertEquals('/v2/project/'.$this->API_KEY.'/archive/'.$this->archiveData['id'], $request->getPath());
144144
$this->assertEquals('api.opentok.com', $request->getHost());
145145
$this->assertEquals('https', $request->getScheme());
146146

@@ -154,7 +154,7 @@ public function testDeletesArchive()
154154
// TODO: test the dynamically built User Agent string
155155
$userAgent = $request->getHeader('User-Agent');
156156
$this->assertNotEmpty($userAgent);
157-
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.4.1-alpha.1', $userAgent->__toString());
157+
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
158158

159159
$this->assertTrue($success);
160160
// TODO: assert that all properties of the archive object were cleared

0 commit comments

Comments
 (0)