This is a .NET implementation of the OpenTok API. See complete documentation at http://www.tokbox.com/opentok/api/tools/documentation/api/server_side_libraries.html.
Install from NuGet
PM > Install-Package OpenTokApi
<configuration>
<appSettings>
<add key="opentok.key" value="***API key***"/>
<add key="opentok.secret" value="***API secret***"/>
<add key="opentok.server" value="https://api.opentok.com"/>
<add key="opentok.token.sentinel" value="T1=="/>
<add key="opentok.sdk.version" value="opentokapi.net"/>
</appSettings>
Explicitly set your OpenTok API key and secret.
To generate an OpenTok session:
var opentok = new OpenTok(); // will pull settings from config
string sessionId = opentok.CreateSession(Request.ServerVariables["REMOTE_ADDR"]);
To generate an OpenTok P2P session:
var opentok = new OpenTok();
string sessionId = opentok.CreateSession(Request.ServerVariables["REMOTE_ADDR"], new { p2p_preference = "enabled" });
To generate a session token:
string token = opentok.GenerateToken(sessionId);
By default, the token has the "publisher" permission. To generate a token with a different set of permissions:
string token = opentok.GenerateToken(sessionId, new { role = Roles.Moderator });
You can also pass in additional token options like "connection_data" and "expire_time":
string token = opentok.GenerateToken(sessionId, new { connection_data = "id = 1", expire_time = DateTime.Now.AddDays(7) });
This library is ported from https://github.com/opentok/Opentok-.NET-SDK
- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don't break it in a future version unintentionally.
- Send me a pull request. Bonus points for topic branches.