Skip to content

Commit 71309ea

Browse files
committed
Merge branch 'master' into jeffswartz-account-portal-docs
2 parents 6698bd4 + 0a98090 commit 71309ea

34 files changed

+703
-340
lines changed

.travis.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ before_script:
1212
- echo $JAVA_OPTS
1313
- export JAVA_OPTS="$JAVA_OPTS -Xmx1024m"
1414
- export GRADLE_OPTS=-Xmx1024m
15+
after_success:
16+
- bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN
1517

1618
# workaround for https://github.com/travis-ci/travis-ci/issues/5227
17-
before_install:
18-
- cat /etc/hosts # optionally check the content *before*
19-
- sudo hostname "$(hostname | cut -c1-63)"
20-
- sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\\1 $(hostname | cut -c1-63)/" /etc/hosts | sudo tee /etc/hosts
21-
- cat /etc/hosts # optionally check the content *after*
19+
addons:
20+
hosts:
21+
- myshorthost
22+
hostname: myshorthost

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# OpenTok Java SDK
22

3-
[![Build Status](https://travis-ci.org/opentok/Opentok-Java-SDK.svg)](https://travis-ci.org/opentok/Opentok-Java-SDK)
4-
3+
[![Build Status](https://travis-ci.org/opentok/Opentok-Java-SDK.svg?branch=master)](https://travis-ci.org/opentok/Opentok-Java-SDK)
4+
[![codecov](https://codecov.io/gh/opentok/Opentok-Java-SDK/branch/master/graph/badge.svg)](https://codecov.io/gh/opentok/Opentok-Java-SDK)
55
The OpenTok Java SDK lets you generate
66
[sessions](http://tokbox.com/opentok/tutorials/create-session/) and
77
[tokens](http://tokbox.com/opentok/tutorials/create-token/) for [OpenTok](http://www.tokbox.com/)
@@ -62,6 +62,12 @@ String apiSecret = "YOUR API SECRET";
6262
OpenTok opentok = new OpenTok(apiKey, apiSecret)
6363
```
6464

65+
And make sure you call `close` when you are done to prevent leaked file descriptors.
66+
67+
```java
68+
opentok.close();
69+
```
70+
6571
## Creating Sessions
6672

6773
To create an OpenTok Session, use the `OpenTok` instance's `createSession(SessionProperties properties)`
@@ -135,7 +141,7 @@ String token = session.generateToken(new TokenOptions.Builder()
135141

136142
You can start the recording of an OpenTok Session using a `com.opentok.OpenTok` instance's
137143
`startArchive(String sessionId, String name)` method. This will return a `com.opentok.Archive` instance.
138-
The parameter `name` is a optional and used to assign a name for the Archive. Note that you can
144+
The parameter `name` is optional and used to assign a name for the Archive. Note that you can
139145
only start an Archive on a Session that has clients connected.
140146

141147
```java

build.gradle

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ apply plugin: 'maven'
77
apply plugin: 'signing'
88
apply plugin: 'idea'
99
apply plugin: 'eclipse'
10+
apply plugin: 'license'
11+
apply plugin: 'jacoco'
1012

1113
group = 'com.tokbox'
1214
archivesBaseName = 'opentok-server-sdk'
13-
version = '3.0.0-beta.2'
15+
version = '3.0.0-beta.3'
1416

1517
task javadocJar(type: Jar) {
1618
classifier = 'javadoc'
@@ -26,6 +28,13 @@ javadoc {
2628
}
2729
}
2830

31+
jacocoTestReport {
32+
reports {
33+
xml.enabled true
34+
html.enabled false
35+
}
36+
}
37+
2938
task sourcesJar(type: Jar) {
3039
classifier = 'sources'
3140
from sourceSets.main.allSource
@@ -38,17 +47,17 @@ repositories {
3847
dependencies {
3948
testCompile group: 'junit', name: 'junit', version: '[4.3,5.0['
4049
testCompile group: 'com.github.tomakehurst', name: 'wiremock', version: '[1.45,1.99999)'
41-
testCompile group: 'commons-lang', name: 'commons-lang', version: '[2.6,2.99999)'
50+
compile group: 'commons-lang', name: 'commons-lang', version: '[2.6,2.99999)'
4251
compile group: 'com.ning', name: 'async-http-client', version: '[1.9,2.0['
4352
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '[2.3.1,2.99999)'
4453
compile group: 'commons-validator', name: 'commons-validator', version: '[1.4.0,1.99999)'
4554
compile group: 'commons-codec', name: 'commons-codec', version: '[1.9,1.99999]'
55+
compile group: 'org.bitbucket.b_c', name: 'jose4j', version: '0.5.1'
4656
// TODO: find out how to initialize these dependencies properly, or remove them
4757
//compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.5'
4858
//compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.5'
4959
}
5060

51-
apply plugin: 'license'
5261
license {
5362
header rootProject.file('codequality/HEADER')
5463
ext.year = Calendar.getInstance().get(Calendar.YEAR)
@@ -132,4 +141,4 @@ tasks.withType(JavaCompile) {
132141
// and other specific JDK jars
133142
}
134143
}
135-
}
144+
}

codecov.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Team Yaml
2+
coverage:
3+
round: down
4+
precision: 5
5+
6+
# Repository Yaml
7+
coverage:
8+
round: up
9+
range: 0..10
10+
11+
# Used in Codecov after updating
12+
coverage:
13+
round: up
14+
range: 0..10
15+
precision: 5

sample/Archiving/public/js/host.js

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,61 @@
1-
var session = OT.initSession(sessionId),
2-
publisher = OT.initPublisher("publisher"),
1+
var session = OT.initSession(apiKey, sessionId),
2+
publisher = OT.initPublisher('publisher'),
33
archiveID = null;
44

5-
session.connect(apiKey, token, function(err, info) {
6-
if(err) {
7-
alert(err.message || err);
5+
session.connect(token, function(error, info) {
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+
});
814
}
9-
session.publish(publisher);
1015
});
1116

1217
session.on('streamCreated', function(event) {
13-
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+
});
1425
});
1526

1627
session.on('archiveStarted', function(event) {
1728
archiveID = event.id;
18-
console.log("ARCHIVE STARTED");
19-
$(".start").hide();
20-
$(".stop").show();
29+
console.log('ARCHIVE STARTED');
30+
$('.start').hide();
31+
$('.stop').show();
2132
disableForm();
2233
});
2334

2435
session.on('archiveStopped', function(event) {
2536
archiveID = null;
26-
console.log("ARCHIVE STOPPED");
27-
$(".start").show();
28-
$(".stop").hide();
37+
console.log('ARCHIVE STOPPED');
38+
$('.start').show();
39+
$('.stop').hide();
2940
enableForm();
3041
});
3142

3243
$(document).ready(function() {
33-
$(".start").click(function (event) {
34-
var options = $(".archive-options").serialize();
44+
$('.start').click(function(event) {
45+
var options = $('.archive-options').serialize();
3546
disableForm();
36-
$.post("/start", options).fail(enableForm);
47+
$.post('/start', options).fail(enableForm);
3748
}).show();
38-
$(".stop").click(function(event){
39-
$.get("stop/" + archiveID);
49+
$('.stop').click(function(event){
50+
$.get('stop/' + archiveID);
4051
}).hide();
4152
});
4253

4354

4455
function disableForm() {
45-
$(".archive-options-fields").attr('disabled', 'disabled');
56+
$('.archive-options-fields').attr('disabled', 'disabled');
4657
}
4758

4859
function enableForm() {
49-
$(".archive-options-fields").removeAttr('disabled');
50-
}
60+
$('.archive-options-fields').removeAttr('disabled');
61+
}
Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1-
var session = OT.initSession(sessionId),
2-
publisher = OT.initPublisher("publisher");
1+
var session = OT.initSession(apiKey, sessionId),
2+
publisher = OT.initPublisher('publisher');
33

4-
session.connect(apiKey, token, function(err, info) {
5-
if(err) {
6-
alert(err.message || err);
4+
session.connect(token, function(error, info) {
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+
});
713
}
8-
session.publish(publisher);
914
});
1015

1116
session.on('streamCreated', function(event) {
12-
session.subscribe(event.stream, "subscribers", { insertMode : "append" });
13-
});
17+
session.subscribe(event.stream, 'subscribers', {
18+
insertMode : 'append'
19+
}, function(error) {
20+
if (error) {
21+
console.error('Failed to subscribe', error);
22+
}
23+
});
24+
});

sample/Archiving/src/main/resources/com/example/freemarker/host.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<#include "header.ftl">
22

3-
<script src="//static.opentok.com/webrtc/v2.2/js/opentok.min.js"></script>
3+
<script src="https://static.opentok.com/v2/js/opentok.min.js"></script>
44

55
<div class="container bump-me">
66

sample/Archiving/src/main/resources/com/example/freemarker/participant.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<#include "header.ftl">
2-
<script src="//static.opentok.com/webrtc/v2.2/js/opentok.min.js"></script>
2+
<script src="https://static.opentok.com/v2/js/opentok.min.js"></script>
33

44
<div class="container bump-me">
55

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
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 element with id="publisher"
5-
var publisher = OT.initPublisher(apiKey, 'publisher');
5+
var publisher = OT.initPublisher('publisher');
66

77
// Attach an event handler for when the session dispatches the 'streamCreated' event.
88
session.on('streamCreated', function(event) {
9-
// This function runs when another client publishes a stream (eg. session.publish())
9+
// This function runs when another client publishes a stream (eg. session.publish())
1010

11-
// Subscribe to the stream that caused this event, put it inside the DOM element with id='subscribers'
12-
session.subscribe(event.stream, 'subscribers', {
13-
insertMode: 'append'
14-
});
11+
// Subscribe to the stream that caused this event, put it inside the DOM element with id='subscribers'
12+
session.subscribe(event.stream, 'subscribers', {
13+
insertMode: 'append'
14+
}, function(error) {
15+
if (error) {
16+
console.error('Failed to subscribe', error);
17+
}
18+
});
1519
});
1620

1721
// Connect to the Session using the 'apiKey' of the application and a 'token' for permission
18-
session.connect(apiKey, token, function(error) {
19-
// This function runs when session.connect() asynchronously completes
20-
21-
// Handle connection errors
22-
if (error) {
23-
return console.error(error);
24-
}
22+
session.connect(token, function(error) {
23+
// This function runs when session.connect() asynchronously completes
2524

25+
// Handle connection errors
26+
if (error) {
27+
console.error('Failed to connect', error);
28+
} else {
2629
// Publish the publisher we initialzed earlier (this will trigger 'streamCreated' on other
2730
// clients)
28-
session.publish(publisher);
31+
session.publish(publisher, function(error) {
32+
if (error) {
33+
console.error('Failed to publish', error);
34+
}
35+
});
36+
}
2937
});

sample/HelloWorld/src/main/resources/com/example/freemarker/index.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8" />
55
<title>OpenTok Hello World</title>
6-
<script src="//static.opentok.com/webrtc/v2.2/js/TB.min.js"></script>
6+
<script src="https://static.opentok.com/v2/js/opentok.min.js"></script>
77
<script type="text/javascript">
88
var apiKey = '${ apiKey }';
99
var sessionId = '${ sessionId }';

src/main/java/com/opentok/Archive.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* OpenTok Java SDK
3-
* Copyright (C) 2016 TokBox, Inc.
3+
* Copyright (C) 2017 TokBox, Inc.
44
* http://www.tokbox.com
55
*
66
* Licensed under The MIT License (MIT). See LICENSE file for more information.
@@ -11,7 +11,7 @@
1111
import com.fasterxml.jackson.databind.ObjectMapper;
1212

1313
/**
14-
* Represents an archive of an OpenTok session.
14+
* Represents an archive of an OpenTok session.
1515
*/
1616
@JsonIgnoreProperties(ignoreUnknown=true)
1717
public class Archive {
@@ -146,9 +146,8 @@ public int getPartnerId() {
146146
}
147147

148148
/**
149-
* For archives with the status of Status.STOPPED, this can be set to "maximum duration
150-
* exceeded", "maximum idle time exceeded", "session ended", "user initiated". For archives
151-
* with the status of Status.FAILED, this can be set to "failure".
149+
* For archives with the status Status.STOPPED or Status.FAILED, this string describes the
150+
* reason the archive stopped (such as "maximum duration exceeded") or failed.
152151
*/
153152
public String getReason() {
154153
return reason;
@@ -161,7 +160,7 @@ public String getSessionId() {
161160
return sessionId;
162161
}
163162

164-
/**
163+
/**
165164
* The size of the MP4 file. For archives that have not been generated, this value is set to 0.
166165
*/
167166
public int getSize() {
@@ -177,7 +176,7 @@ public Status getStatus() {
177176

178177
/**
179178
* The download URL of the available MP4 file. This is only set for an archive with the status
180-
* set to Status.AVAILABLE; for other archives, (including archives with the status of
179+
* set to Status.AVAILABLE; for other archives, (including archives with the status of
181180
* Status.UPLOADED) this method returns null. The download URL is obfuscated, and the file
182181
* is only available from the URL for 10 minutes. To generate a new URL, call the
183182
* {@link com.opentok.OpenTok#listArchives()} or {@link com.opentok.OpenTok#getArchive(String)}
@@ -202,7 +201,7 @@ public boolean hasAudio() {
202201
}
203202

204203
/**
205-
* The output mode to be generated for this archive: <code>composed</code> or <code>individual</code>.
204+
* The output mode to be generated for this archive: <code>composed</code> or <code>individual</code>.
206205
*/
207206
public OutputMode getOutputMode() {
208207
return outputMode;
@@ -215,7 +214,7 @@ public String toString() {
215214
} catch (Exception e) {
216215
return "";
217216
}
218-
217+
219218
}
220219

221-
}
220+
}

src/main/java/com/opentok/ArchiveList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* OpenTok Java SDK
3-
* Copyright (C) 2016 TokBox, Inc.
3+
* Copyright (C) 2017 TokBox, Inc.
44
* http://www.tokbox.com
55
*
66
* Licensed under The MIT License (MIT). See LICENSE file for more information.

src/main/java/com/opentok/ArchiveMode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* OpenTok Java SDK
3-
* Copyright (C) 2016 TokBox, Inc.
3+
* Copyright (C) 2017 TokBox, Inc.
44
* http://www.tokbox.com
55
*
66
* Licensed under The MIT License (MIT). See LICENSE file for more information.

0 commit comments

Comments
 (0)