Skip to content

Commit 97f56fb

Browse files
committed
Edits to Javadoc comments.
1 parent 58aeb35 commit 97f56fb

File tree

10 files changed

+290
-160
lines changed

10 files changed

+290
-160
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,29 @@ public class Archive {
1414
*/
1515
public enum Status {
1616
/**
17-
* The archive file is AVAILABLE for download from the OpenTok cloud. You can get the URL of
17+
* The archive file is available for download from the OpenTok cloud. You can get the URL of
1818
* the download file by calling the {@link Archive#getUrl} method.
1919
*/
2020
AVAILABLE,
2121
/**
22-
* The archive file has been DELETED.
22+
* The archive file has been deleted.
2323
*/
2424
DELETED,
2525
/**
26-
* The recording of the archive FAILED.
26+
* The recording of the archive failed.
2727
*/
2828
FAILED,
2929
/**
30-
* The archive recording has STARTED and is in progress.
30+
* The archive recording has started and is in progress.
3131
*/
3232
STARTED,
3333
/**
34-
* The archive recording has STOPPED, but the file is not AVAILABLE.
34+
* The archive recording has stopped, but the file is not available.
3535
*/
3636
STOPPED,
3737
/**
38-
* The archive file is AVAILABLE at the target S3 bucket you specified using the
39-
* REST API.
38+
* The archive file is available at the target S3 bucket you at the
39+
* <a href="https://dashboard.tokbox.com">OpenTok dashboard</a>.
4040
*/
4141
UPLOADED;
4242

src/main/java/com/opentok/OpenTok.java

Lines changed: 100 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public class OpenTok {
5555
/**
5656
* Creates an OpenTokSDK object.
5757
*
58-
* @param apiKey Your OpenTok API key. (See the <a href="https://dashboard.tokbox.com">OpenTok dashboard</a>
59-
* page)
58+
* @param apiKey Your OpenTok API key. (See the <a href="https://dashboard.tokbox.com">OpenTok
59+
* dashboard</a> page.)
6060
* @param apiSecret Your OpenTok API secret. (See the <a href="https://dashboard.tokbox.com">OpenTok dashboard</a>
6161
* page)
6262
*/
@@ -73,33 +73,15 @@ public OpenTok(int apiKey, String apiSecret, String apiUrl) {
7373
}
7474

7575
/**
76-
* Creates a token for connecting to an OpenTok session. In order to authenticate a user connecting to an OpenTok session
77-
* that user must pass an authentication token along with the API key.
78-
* The following Java code example shows how to obtain a token:
79-
* <p>
80-
* <pre>
81-
* import com.opentok.api.OpenTokSDK;
82-
*
83-
* class Test {
84-
* public static void main(String argv[]) throws OpenTokException {
85-
* int API_KEY = 0; // Replace with your OpenTok API key (see http://dashboard.tokbox.com).
86-
* String API_SECRET = ""; // Replace with your OpenTok API secret.
87-
* OpenTokSDK sdk = new OpenTokSDK(API_KEY, API_SECRET);
88-
*
89-
* //Generate a basic session. Or you could use an existing session ID.
90-
* String sessionId = System.out.println(sdk.createSession());
91-
*
92-
* String token = sdk.generateToken(sessionId);
93-
* System.out.println(token);
94-
* }
95-
* }
96-
* </pre>
76+
* Creates a token for connecting to an OpenTok session. In order to authenticate a user
77+
* connecting to an OpenTok session, the client passes a token when connecting to the session.
9778
* <p>
98-
* The following Java code example shows how to obtain a token that has a role of "subscriber" and that has
99-
* a connection metadata string:
79+
* The following example shows how to obtain a token that has a role of "subscriber" and
80+
* that has a connection metadata string:
10081
* <p>
10182
* <pre>
10283
* import com.opentok.Role;
84+
* import com.opentok.TokenOptions;
10385
*
10486
* class Test {
10587
* public static void main(String argv[]) throws OpenTokException {
@@ -116,37 +98,27 @@ public OpenTok(int apiKey, String apiSecret, String apiUrl) {
11698
* // Use the Role value appropriate for the user.
11799
* String role = Role.SUBSCRIBER;
118100
*
119-
* // Generate a token.
120-
* String token = sdk.generateToken(sessionId, Role.PUBLISHER, null, connectionMetadata);
101+
* // Generate a token:
102+
* TokenOptions options = new TokenOptions.Buider().role(role).data(connectionMetadata).build();
103+
* String token = sdk.generateToken(sessionId, options);
121104
* System.out.println(token);
122105
* }
123106
* }
124107
* </pre>
125108
* <p>
126-
* For testing, you can also use the <a href="https://dashboard.tokbox.com/projects">OpenTok dashboard</a>
127-
* page to generate test tokens.
109+
* For testing, you can also use the <a href="https://dashboard.tokbox.com/projects">OpenTok
110+
* dashboard</a> page to generate test tokens.
128111
*
129112
* @param sessionId The session ID corresponding to the session to which the user will connect.
130113
*
131-
* @param role Each role defines a set of permissions granted to the token.
132-
* Valid values are defined in the Role class:
133-
*
134-
* * `SUBSCRIBER` &mdash; A subscriber can only subscribe to streams.</li>
135-
*
136-
* * `PUBLISHER` &mdash; A publisher can publish streams, subscribe to streams, and signal.
137-
* (This is the default value if you do not specify a value for the `role` parameter.)</li>
138-
*
139-
* * `MODERATOR` &mdash; In addition to the privileges granted to a publisher, a moderator
140-
* can call the `forceUnpublish()` and `forceDisconnect()` method of the
141-
* Session object.</li>
142-
*
143-
* @param expireTime The expiration time, in seconds, since the UNIX epoch. Pass in 0 to use
144-
* the default expiration time of 24 hours after the token creation time. The maximum expiration
145-
* time is 30 days after the creation time.
114+
* @param tokenOptions This TokenOptions object defines options for the token.
115+
* These include the following:
146116
*
147-
* @param connectionData A string containing metadata describing the end-user. For example, you can pass the
148-
* user ID, name, or other data describing the end-user. The length of the string is limited to 1000 characters.
149-
* This data cannot be updated once it is set.
117+
* <ul>
118+
* <li>The role of the token (subscriber, publisher, or moderator)</li>
119+
* <li>The expiration time of the token</li>
120+
* <li>Connection data describing the end-user</li>
121+
* </ul>
150122
*
151123
* @return The token string.
152124
*/
@@ -170,49 +142,68 @@ public String generateToken(String sessionId, TokenOptions tokenOptions) throws
170142
return session.generateToken(tokenOptions);
171143
}
172144

173-
public String generateToken(String sessionId) throws OpenTokException {
174-
return generateToken(sessionId, new TokenOptions.Builder().build());
175-
}
176-
177145
/**
178-
* Creates a new OpenTok session and returns the session ID, which uniquely identifies the session.
179-
* <p>
180-
* For example, when using the OpenTok JavaScript library,
181-
* use the session ID in JavaScript on the page that you serve to the client. The JavaScript will use this
182-
* value when calling the <a href="http://tokbox.com/opentok/libraries/client/js/reference/Session.html#connect">connect()</a>
183-
* method of the Session object (to connect a user to an OpenTok session).
184-
* <p>
185-
* OpenTok sessions do not expire. However, authentication tokens do expire (see the
186-
* {@link #generateToken(String, String, long, String)} method).
187-
* Also note that sessions cannot explicitly be destroyed.
188-
* <p>
189-
* A session ID string can be up to 255 characters long.
146+
* Creates a token for connecting to an OpenTok session, using the default settings. The default
147+
* settings are the following:
148+
*
149+
* <ul>
150+
* <li>The token is assigned the role of publisher.</li>
151+
* <li>The token expires 24 hours after it is created.</li>
152+
* <li>The token includes no connection data.</li>
153+
* </ul>
154+
*
190155
* <p>
191-
* Calling this method results in an {@link com.opentok.exception.OpenTokException} in the event of an error. Check
192-
* the error message for details.
156+
* The following example shows how to generate a token that has the default settings:
193157
* <p>
194-
* The following code creates a session that uses the OpenTok Media Router:
195-
*
196158
* <pre>
197-
* import com.opentok.api.OpenTokSDK;
198-
* import com.opentok.SessionProperties;
159+
* import com.opentok.OpenTokSDK;
199160
*
200161
* class Test {
201162
* public static void main(String argv[]) throws OpenTokException {
202-
* int API_KEY = 0; // Replace with your OpenTok API key.
163+
* int API_KEY = 0; // Replace with your OpenTok API key (see http://dashboard.tokbox.com).
203164
* String API_SECRET = ""; // Replace with your OpenTok API secret.
204165
* OpenTokSDK sdk = new OpenTokSDK(API_KEY, API_SECRET);
205166
*
206-
* String sessionId = sdk.createSession();
207-
* System.out.println(sessionId);
167+
* //Generate a basic session. Or you could use an existing session ID.
168+
* String sessionId = System.out.println(sdk.createSession().getSessionId());
169+
*
170+
* String token = sdk.generateToken(sessionId);
171+
* System.out.println(token);
208172
* }
209173
* }
210174
* </pre>
175+
* @param sessionId The session ID corresponding to the session to which the user will connect.
176+
*
177+
* @return The token string.
211178
*
179+
* @see #generateToken(String, TokenOptions)
180+
*/
181+
public String generateToken(String sessionId) throws OpenTokException {
182+
return generateToken(sessionId, new TokenOptions.Builder().build());
183+
}
184+
185+
/**
186+
* Creates a new OpenTok session and returns the session ID, which uniquely identifies
187+
* the session.
188+
* <p>
189+
* For example, when using the OpenTok JavaScript library, use the session ID when calling the
190+
* <a href="http://tokbox.com/opentok/libraries/client/js/reference/OT.html#initSession">
191+
* OT.initSession()</a> method (to initialize an OpenTok session).
192+
* <p>
193+
* OpenTok sessions do not expire. However, authentication tokens do expire (see the
194+
* {@link #generateToken(String, TokenOptions)} method). Also note that sessions cannot
195+
* explicitly be destroyed.
196+
* <p>
197+
* A session ID string can be up to 255 characters long.
198+
* <p>
199+
* Calling this method results in an {@link com.opentok.exception.OpenTokException} in
200+
* the event of an error. Check the error message for details.
201+
* <p>
212202
* The following code creates a peer-to-peer session:
213203
*
214204
* <pre>
215-
* import com.opentok.api.OpenTokSDK;
205+
* import com.opentok.OpenTokSDK;
206+
* import com.opentok.Session;
216207
* import com.opentok.SessionProperties;
217208
*
218209
* class Test {
@@ -221,41 +212,25 @@ public String generateToken(String sessionId) throws OpenTokException {
221212
* String API_SECRET = ""; // Replace with your OpenTok API secret.
222213
* OpenTokSDK sdk = new OpenTokSDK(API_KEY, API_SECRET);
223214
*
224-
* SessionProperties sp = new SessionProperties();
225-
* sp.p2p_preference = "enabled";
215+
* SessionProperties sp = new SessionProperties().Builder().p2p(true).build();
226216
*
227-
* String sessionId = sdk.createSession(null, sp);
228-
* System.out.println(sessionId);
217+
* Session session = sdk.createSession(sp);
218+
* System.out.println(session.getSessionId());
229219
* }
230220
* }
231221
* </pre>
232222
*
233223
* You can also create a session using the <a href="http://www.tokbox.com/opentok/api/#session_id_production">OpenTok
234224
* REST API</a> or the <a href="https://dashboard.tokbox.com/projects">OpenTok dashboard</a>.
235225
*
236-
* @param properties Defines whether the session's streams will be transmitted directly between peers or
237-
* using the OpenTok media server. You can set the following possible values:
238-
* <p>
226+
* @param properties This SessionProperties object defines options for the session.
227+
* These include the following:
228+
*
239229
* <ul>
240-
* <li>
241-
* "disabled" (the default) &mdash; The session's streams will all be relayed using the OpenTok media server.
242-
* <br><br>
243-
* <i>In OpenTok v2:</i> The <a href="http://www.tokbox.com/blog/mantis-next-generation-cloud-technology-for-webrtc/">OpenTok
244-
* media server</a> provides benefits not AVAILABLE in peer-to-peer sessions. For example, the OpenTok media server can
245-
* decrease bandwidth usage in multiparty sessions. Also, the OpenTok server can improve the quality of the user experience
246-
* through <a href="http://www.tokbox.com/blog/quality-of-experience-and-traffic-shaping-the-next-step-with-mantis/">dynamic
247-
* traffic shaping</a>. For information on pricing, see the <a href="http://www.tokbox.com/pricing">OpenTok pricing page</a>.
248-
* <br><br>
249-
* </li>
250-
* <li>
251-
* "enabled" &mdash; The session will attempt to transmit streams directly between clients.
252-
* <br><br>
253-
* <i>In OpenTok v1:</i> Peer-to-peer streaming decreases latency and improves quality. If peer-to-peer streaming
254-
* fails (either when streams are initially published or during the course of a session), the session falls back to using
255-
* the OpenTok media server to relaying streams. (Peer-to-peer streaming uses UDP, which may be blocked by a firewall.)
256-
* For a session created with peer-to-peer streaming enabled, only two clients can connect to the session at a time.
257-
* If an additional client attempts to connect, the client dispatches an exception event.
258-
* </li>
230+
* <li>Whether the session's streams will be transmitted directly between peers or
231+
* using the OpenTok Media Router.</li>
232+
*
233+
* <li>A location hint for the location of the OpenTok server to use for the session.</li>
259234
* </ul>
260235
*
261236
* @return A session ID for the new session. For example, when using the OpenTok JavaScript library, use this session ID
@@ -289,9 +264,32 @@ public Session createSession(SessionProperties properties) throws OpenTokExcepti
289264
}
290265

291266
/**
292-
* Creates an OpenTok session and returns the session ID, with the default properties. The
293-
* session uses the OpenTok media server. And the session uses the first client connecting
294-
* to determine the location of OpenTok server to use.
267+
* Creates an OpenTok session with the default settings:
268+
*
269+
* <ul>
270+
* <li>The session uses the OpenTok media server.
271+
* <li>The session uses the first client connecting to determine the location of the
272+
* OpenTok server to use.</li>
273+
* </ul>
274+
*
275+
* <p>
276+
* The following example creates a session that uses the default settings:
277+
*
278+
* <pre>
279+
* import com.opentok.OpenTokSDK;
280+
* import com.opentok.SessionProperties;
281+
*
282+
* class Test {
283+
* public static void main(String argv[]) throws OpenTokException {
284+
* int API_KEY = 0; // Replace with your OpenTok API key.
285+
* String API_SECRET = ""; // Replace with your OpenTok API secret.
286+
* OpenTokSDK sdk = new OpenTokSDK(API_KEY, API_SECRET);
287+
*
288+
* String sessionId = sdk.createSession();
289+
* System.out.println(sessionId);
290+
* }
291+
* }
292+
* </pre>
295293
*
296294
* @see #createSession(SessionProperties)
297295
*/

src/main/java/com/opentok/Role.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,24 @@
77

88
package com.opentok;
99
/**
10-
* Defines values for the role parameter of the <code>OpenTokSDK.generateToken()</code> method.
11-
*
12-
* @see <a href="../OpenTokSDK.html#generateToken(java.lang.String, java.lang.String)">OpenTokSDK.generateTokentoken(String, String)</a>
13-
* @see <a href="../OpenTokSDK.html#generateToken(java.lang.String, java.lang.String, java.lang.Long)">OpenTokSDK.generateTokentoken(String, String, Long)</a>
14-
* @see <a href="../OpenTokSDK.html#generateTokentoken(java.lang.String, java.lang.String, java.lang.Long, java.lang.String)">OpenTokSDK.generateTokentoken(String, String, Long, String)</a>
10+
* Defines values for the role parameter of the {@link TokenOptions.Builder#role(Role role)} method.
1511
*/
1612
public enum Role {
13+
/**
14+
* A subscriber can only subscribe to streams.
15+
*/
1716
SUBSCRIBER,
17+
/**
18+
* A publisher can publish streams, subscribe to streams, and signal. (This is the default
19+
* value if you do not set a roll by calling the {@link TokenOptions.Builder#role(Role role)}
20+
* method.
21+
*/
1822
PUBLISHER,
23+
/**
24+
* In addition to the privileges granted to a publisher, in clients using the OpenTok.js 2.2
25+
* library, a moderator can call the <code>forceUnpublish()</code> and
26+
* <code>forceDisconnect()</code> method of the Session object.
27+
*/
1928
MODERATOR;
2029

2130
@Override

0 commit comments

Comments
 (0)