1
1
# OpenTok .NET SDK
2
2
3
- [ ![ Build status ] ( https://ci.appveyor .com/api/projects/status/tw2d8ufd3tpwkf5b? svg=true ) ]( https://ci.appveyor .com/project/aoberoi/opentok-net-sdk ) [ ![ Build Status ] ( https://travis-ci.org/opentok/Opentok-.NET-SDK. svg)] ( https://travis-ci.org/opentok/Opentok-.NET-SDK )
3
+ ![ https://assets.tokbox .com/img/vonage/Vonage_VideoAPI_black. svg ] ( https://assets.tokbox .com/img/vonage/Vonage_VideoAPI_black. svg )
4
4
5
+ [ ![ Build status] ( https://ci.appveyor.com/api/projects/status/tw2d8ufd3tpwkf5b?svg=true )] ( https://ci.appveyor.com/project/aoberoi/opentok-net-sdk ) [ ![ Build Status] ( https://travis-ci.org/opentok/Opentok-.NET-SDK.svg )] ( https://travis-ci.org/opentok/Opentok-.NET-SDK )
5
6
6
7
The OpenTok .NET SDK lets you generate
7
8
[ sessions] ( https://www.tokbox.com/opentok/tutorials/create-session/ ) and
8
9
[ tokens] ( https://www.tokbox.com/opentok/tutorials/create-token/ ) for
9
10
[ OpenTok] ( https://www.tokbox.com/ ) applications that run on the .NET platform. The SDK also includes
10
11
support for working with [ OpenTok archives] ( https://tokbox.com/opentok/tutorials/archiving ) .
11
12
12
- # Installation
13
+ ## Installation
13
14
14
- ## NuGet (recommended):
15
+ ### NuGet (recommended):
15
16
16
17
Using the [ Package Manager Console] ( http://docs.nuget.org/consume/package-manager-console ) :
17
18
18
19
```
19
20
PM> Install-Package OpenTok
20
21
```
21
22
22
- ## Manually:
23
+ ### Manually:
23
24
24
25
Download the latest release from the [ Releases Page] ( https://github.com/opentok/Opentok-.NET-SDK/releases ) .
25
26
Unzip the file and place the place the ` OpenTok.dll ` , dependent assemblies, and supporting files into your
26
27
own project.
27
28
28
- # Usage
29
+ ## Usage
29
30
30
- ## Initializing
31
+ ### Initializing
31
32
32
33
Import the ` OpenTokSDK ` namespace into any files that will be using OpenTok objects. Then initialize an
33
34
` OpenTokSDK.OpenTok ` object using your own API Key and API Secret.
@@ -42,19 +43,19 @@ string ApiSecret = "YOUR API SECRET";
42
43
var OpenTok = new OpenTok (ApiKey , ApiSecret );
43
44
```
44
45
45
- ## Creating Sessions
46
+ ### Creating Sessions
46
47
47
48
To create an OpenTok Session, call the ` OpenTok ` instance's
48
49
` CreateSession(string location, MediaMode mediaMode, ArchiveMode archiveMode) `
49
50
method. Each of the parameters are optional and can be omitted if not needed. They are:
50
51
51
- * ` string location ` : An IPv4 address used as a location hint. (default: "")
52
+ - ` string location ` : An IPv4 address used as a location hint. (default: "")
52
53
53
- * ` MediaMode mediaMode ` : Specifies whether the session will use the OpenTok Media Router
54
- (MediaMode.ROUTED) or attempt to transmit streams directly between clients
55
- (MediaMode.RELAYED, the default)
54
+ - ` MediaMode mediaMode ` : Specifies whether the session will use the OpenTok Media Router
55
+ (MediaMode.ROUTED) or attempt to transmit streams directly between clients
56
+ (MediaMode.RELAYED, the default)
56
57
57
- * ` ArchiveMode archiveMode ` : Specifies whether the session will be automatically archived
58
+ - ` ArchiveMode archiveMode ` : Specifies whether the session will be automatically archived
58
59
(ArchiveMode.ALWAYS) or not (ArchiveMode.MANUAL, the default)
59
60
60
61
The return value is a ` OpenTokSDK.Session ` object. Its ` Id ` property is useful to get an identifier that can be saved to a
@@ -77,7 +78,7 @@ var session = OpenTok.CreateSession(mediaMode: MediaMode.ROUTED, ArchiveMode.ALW
77
78
string sessionId = session .Id ;
78
79
```
79
80
80
- ## Generating Tokens
81
+ ### Generating Tokens
81
82
82
83
Once a Session is created, you can start generating Tokens for clients to use when connecting to it.
83
84
You can generate a token either by calling an ` OpenTokSDK.OpenTok ` instance's
@@ -99,7 +100,7 @@ string token = session.GenerateToken(role: Role.MODERATOR, expireTime: inOneWeek
99
100
100
101
```
101
102
102
- ## Working with Archives
103
+ ### Working with Archives
103
104
104
105
You can start the recording of an OpenTok Session using a ` OpenTokSDK.OpenTok ` instance's
105
106
` StartArchive(sessionId, name, hasVideo, hasAudio, outputMode, resolution) ` method. This will return an
@@ -113,6 +114,7 @@ var archive = OpenTok.StartArchive(sessionId);
113
114
// Store this archive ID in the database for later use
114
115
Guid archiveId = archive .Id ;
115
116
```
117
+
116
118
You can add a name for the archive (to use for identification) by setting the ` name ` parameter of
117
119
the ` OpenTok.StartArchive() ` method.
118
120
@@ -172,7 +174,7 @@ Note that you can also create an automatically archived session, by passing in `
172
174
as the ` archiveMode ` parameter when you call the ` OpenTok.CreateSession() ` method (see "Creating
173
175
Sessions," above).
174
176
175
- ## Working with Streams
177
+ ### Working with Streams
176
178
177
179
You can get information about a stream by calling the ` GetStream(sessionId, streamId) ` method of the ` OpenTok ` class.
178
180
@@ -188,29 +190,31 @@ stream.LayoutClassList; // list with the layout class list
188
190
189
191
You can get information about all the streams in a session by calling the ` ListStreams(sessionId) ` method of the ` OpenTok ` class.
190
192
191
-
192
193
``` csharp
193
194
StreamList streamList = OpenTok .ListStreams (sessionId );
194
195
195
- streamList .Count ; // total count
196
+ streamList .Count ; // total count
196
197
```
197
198
198
- ## Force Disconnecting
199
+ ### Force Disconnecting
199
200
200
201
Your application server can disconnect a client from an OpenTok session by calling the ` ForceDisconnect(sessionId, connectionId) ` method of the ` OpenTok ` class.
201
202
202
203
``` csharp
203
204
// Force disconnect a client connection
204
205
OpenTok .ForceDisconnect (sessionId , connectionId );
205
206
```
206
- ## Sending Signals
207
+
208
+ ### Sending Signals
209
+
207
210
Once a Session is created, you can send signals to everyone in the session or to a specific connection. You can send a signal by calling the ` Signal(sessionId, signalProperties, connectionId) ` method of the ` OpenTok ` class.
208
211
209
212
The ` sessionId ` parameter is the session ID of the session.
210
213
211
214
The ` signalProperties ` parameter is an instance of the ` SignalProperties ` class where you can set the ` data ` paramter and the ` type ` parameter.
212
- * ` data ` (string) -- The data string for the signal. You can send a maximum of 8kB.
213
- * ` type ` (string) -- (Optional) The type string for the signal. You can send a maximum of 128 charaacters, and only the following characters are allowed: A-Z, a-z, numbers (0-9), '-', '_ ', and '~ '.
215
+
216
+ - ` data ` (string) -- The data string for the signal. You can send a maximum of 8kB.
217
+ - ` type ` (string) -- (Optional) The type string for the signal. You can send a maximum of 128 charaacters, and only the following characters are allowed: A-Z, a-z, numbers (0-9), '-', '\_ ', and '~ '.
214
218
215
219
The ` connectionId ` parameter is an optional string used to specify the connection ID of a client conencted to the session. If you specify this value, the signal is sent to the specified client. Otherwise, the signal is sent to all clients connected to the session.
216
220
@@ -223,35 +227,37 @@ string connectionId = "CONNECTIONID";
223
227
OpenTok .Signal (sessionId , signalProperties , connectionId );
224
228
```
225
229
226
- # Samples
230
+ ## Samples
227
231
228
232
There are two sample applications included with the SDK. To get going as fast as possible, clone the whole
229
233
repository and follow the Walkthroughs:
230
234
231
- * [ HelloWorld] ( Samples/HelloWorld/README.md )
232
- * [ Archiving] ( Samples/Archiving/README.md )
235
+ - [ HelloWorld] ( Samples/HelloWorld/README.md )
236
+ - [ Archiving] ( Samples/Archiving/README.md )
233
237
234
- # Documentation
238
+ ## Documentation
235
239
236
240
Reference documentation is available at < https://tokbox.com/developer/sdks/dot-net/reference/ > .
237
241
238
- # Requirements
242
+ ## Requirements
239
243
240
244
You need an OpenTok API key and API secret, which you can obtain by logging into your
241
245
[ TokBox account] ( https://tokbox.com/account ) .
242
246
243
247
The OpenTok .NET SDK requires .NET Framework 4.5.2 or greater.
248
+
244
249
> NOTE: When using on 4.5.2 TLS 1.2 is not enabled by default. You should use something like the following to force the runtime onto at least TLS 1.2
250
+
245
251
```
246
252
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
247
253
```
248
254
249
- # Release Notes
255
+ ## Release Notes
250
256
251
257
See the [ Releases] ( https://github.com/opentok/opentok-.net-sdk/releases ) page for details
252
258
about each release.
253
259
254
- ## Important changes since v2.2.0
260
+ ### Important changes since v2.2.0
255
261
256
262
** Changes in v3.0.0:**
257
263
@@ -272,11 +278,11 @@ This version of the SDK includes support for working with OpenTok archives.
272
278
This version of the SDK includes a number of improvements in the API design. These include a number
273
279
of API changes:
274
280
275
- * New OpenTok class -- The name of the main class has changed from OpenTokSDK to OpenTok.
281
+ - New OpenTok class -- The name of the main class has changed from OpenTokSDK to OpenTok.
276
282
In the previous version, the constructor was ` OpenTokSDK() ` .
277
283
In v2.2, it is ` OpenTok(int apiKey, int apiSecret) ` .
278
284
279
- * CreateSession -- In the previous version, there were two methods to create a session:
285
+ - CreateSession -- In the previous version, there were two methods to create a session:
280
286
` OpenTokSDK.CreateSession(String location) ` and
281
287
` OpenTokSDK.CreateSession(String location, Dictionary<string, object> options) ` .
282
288
These methods returned a string (the session ID).
@@ -285,25 +291,31 @@ of API changes:
285
291
` CreateSession(string location = "", MediaMode mediaMode = MediaMode.ROUTED) ` .
286
292
The ` mediaMode ` parameter replaces the ` p2p.preference ` setting in the
287
293
previous version. The method returns a Session Object.
288
-
289
- * GenerateToken -- In the previous version, there were two methods:
294
+
295
+ - GenerateToken -- In the previous version, there were two methods:
290
296
` OpenTokSDK.GenerateToken(string sessionId) ` and
291
297
` OpenTokSDK.GenerateToken(string sessionId, Dictionary<string, object> options) `
292
298
In v2.2, this is replaced with the following method:
293
299
` OpenTokSDK.OpenTok.GenerateToken(string sessionId, Role role = Role.PUBLISHER, double expireTime = 0, string data = null) ` .
294
300
All parameters, except the ` sessionId ` parameter, are optional.
295
-
301
+
296
302
Also, the Session class includes a method for generating tokens:
297
303
` OpenTokSDK.Session.GenerateToken(Role role = Role.PUBLISHER, double expireTime = 0, string data = null) ` .
298
304
299
- # Development and Contributing
305
+ ## Development and Contributing
300
306
301
307
Interested in contributing? We :heart : pull requests! See the [ Development] ( DEVELOPING.md ) and
302
308
[ Contribution] ( CONTRIBUTING.md ) guidelines.
303
309
304
- # Support
310
+ ## Getting Help
311
+
312
+ We love to hear from you so if you have questions, comments or find a bug in the project, let us know! You can either:
313
+
314
+ - Open an issue on this repository
315
+ - See < https://support.tokbox.com/ > for support options
316
+ - Tweet at us! We're [ @VonageDev on Twitter] ( https://twitter.com/VonageDev )
317
+ - Or [ join the Vonage Developer Community Slack] ( https://developer.nexmo.com/community/slack )
305
318
306
- See < https://support.tokbox.com/ > for all our support options.
319
+ ## Further Reading
307
320
308
- Find a bug? File it on the [ Issues] ( https://github.com/opentok/opentok-.net-sdk/issues ) page. Hint:
309
- test cases are really helpful!
321
+ - Check out the Developer Documentation at < https://tokbox.com/developer/ >
0 commit comments