Giter Site home page Giter Site logo

opentok-.net-sdk's Introduction

OpenTok .NET SDK

Tokbox is now known as Vonage

Build status Contributor Covenant

The OpenTok .NET SDK provides methods for:

Note!

This library is designed to work with the Tokbox/OpenTok platform, part of the Vonage Video API. If you are looking to use the Vonage Video API and using the Vonage Customer Dashboard, you will want to install the [Vonage Server SDK for ](link to core SDK), which includes support for the Vonage Video API.

Not sure which exact platform you are using? Take a look at this guide.

If you are using the Tokbox platform, do not worry! The Tokbox platform is not going away, and this library will continue to be updated. While we encourage customers to check out the new Unified platform, there is no rush to switch. Both platforms run the exact same infrastructure and capabilities, with the main difference is a unified billing interface and easier access to Vonage’s other CPaaS APIs.

If you are new to the Vonage Video API, head on over to the Vonage Customer Dashboard to sign up for a developer account and check out the [Vonage Server SDK for ](link to core SDK).

Installation

NuGet (recommended):

Using the Package Manager Console:

PM> Install-Package OpenTok

Manually:

Download the latest release from the Releases Page. Unzip the file and place the place the OpenTok.dll, dependent assemblies, and supporting files into your own project.

Usage

Initializing

Import the OpenTokSDK namespace into any files that will be using OpenTok objects. Then initialize an OpenTokSDK.OpenTok object using your own API Key and API Secret.

using OpenTokSDK;

// ...

int ApiKey = 000000; // YOUR API KEY
string ApiSecret = "YOUR API SECRET";
var OpenTok = new OpenTok(ApiKey, ApiSecret);

Overriding the request's user-agent value

You can decide to add a custom value to the user-agent value passed with every request.

var OpenTok = new OpenTok(ApiKey, ApiSecret);
OpenTok.SetCustomUserAgent(customUserAgent);

If the custom value has been set, the user-agent will comply to the following format: Opentok-DotNet-SDK/{version}/{customValue}.

Creating Sessions

To create an OpenTok Session, call the OpenTok instance's CreateSession(string location, MediaMode mediaMode, ArchiveMode archiveMode) or CreateSessionAsync(string location, MediaMode mediaMode, ArchiveMode archiveMode) method. Each of the parameters are optional and can be omitted if not needed. They are:

  • string location : An IPv4 address used as a location hint. (default: "")

  • MediaMode mediaMode : Specifies whether the session will use the OpenTok Media Router (MediaMode.ROUTED) or attempt to transmit streams directly between clients (MediaMode.RELAYED, the default)

  • ArchiveMode archiveMode : Specifies whether the session will be automatically archived (ArchiveMode.ALWAYS) or not (ArchiveMode.MANUAL, the default)

The return value is a OpenTokSDK.Session object. Its Id property is useful to get an identifier that can be saved to a persistent store (such as a database).

// Create a session that will attempt to transmit streams directly between clients
var session = OpenTok.CreateSession();
// Store this sessionId in the database for later use:
string sessionId = session.Id;

// Create a session that uses the OpenTok Media Router (which is required for archiving)
var session = OpenTok.CreateSession(mediaMode: MediaMode.ROUTED);
// Store this sessionId in the database for later use:
string sessionId = session.Id;

// Create an automatically archived session:
var session = OpenTok.CreateSession(mediaMode: MediaMode.ROUTED, ArchiveMode.ALWAYS);
// Store this sessionId in the database for later use:
string sessionId = session.Id;

Generating Tokens

Once a Session is created, you can start generating Tokens for clients to use when connecting to it. You can generate a token either by calling an OpenTokSDK.OpenTok instance's GenerateToken(string sessionId, Role role, double expireTime, string data) method, or by calling a OpenTokSDK.Session instance's GenerateToken(Role role, double expireTime, string data) method after creating it. In the first method, the sessionId is required and the rest of the parameters are optional. In the second method, all the parameters are optional.

// Generate a token from a sessionId (fetched from database)
string token = OpenTok.GenerateToken(sessionId);

// Generate a token by calling the method on the Session (returned from CreateSession)
string token = session.GenerateToken();

// Set some options in a token
double inOneWeek = (DateTime.UtcNow.Add(TimeSpan.FromDays(7)).Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
string token = session.GenerateToken(role: Role.MODERATOR, expireTime: inOneWeek, data: "name=Johnny");

Working with Archives

You can start the recording of an OpenTok Session using a OpenTokSDK.OpenTok instance's StartArchive(sessionId, name, hasVideo, hasAudio, outputMode, resolution) method. This will return an OpenTokSDK.Archive instance. The parameter name is optional and used to assign a name for the Archive. Note that you can only start an Archive on a Session that has clients connected.

// A simple Archive (without a name)
var archive = OpenTok.StartArchive(sessionId);

or

// A simple Archive (without a name)
var archive = await OpenTok.StartArchiveAsync(sessionId);

then

// Store this archive ID in the database for later use
Guid archiveId = archive.Id;

You can add a name for the archive (to use for identification) by setting the name parameter of the OpenTok.StartArchive() method.

You can also disable audio or video recording by setting the hasAudio or hasVideo parameter of the OpenTok.StartArchive() method false.

You can also set the resolution of the recording to high definition by setting the resolution parameter of the OpenTok.StartArchive() method. Accepted values are "640x480" (SD landscape, the default), "1280x720" (HD landscape), "1920x1080" (FHD landscape), "480x640" (SD portrait), "720x1280" (HD portrait), or "1080x1920" (FHD portrait). Please note that you cannot specify the resolution when you set the outputMode parameter to OutputMode.INDIVIDUAL.

By default, all streams are recorded to a single (composed) file. You can record the different streams in the session to individual files (instead of a single composed file) by setting the outputMode parameter of the OpenTok.StartArchive() method OutputMode.INDIVIDUAL.

You can stop the recording of a started Archive using a OpenTokSDK.OpenTok instance's StopArchive(String archiveId) method or using the OpenTokSDK.Archive instance's Stop() method.

// Stop an Archive from an archive ID (fetched from database)
var archive = OpenTok.StopArchive(archiveId);

or

var archive = OpenTok.StopArchiveAsync(archiveId);

To get an OpenTokSDK.Archive instance (and all the information about it) from an archive ID, use the OpenTokSDK.OpenTok instance's GetArchive(archiveId) method.

var archive = OpenTok.GetArchive(archiveId);

or

var archive = OpenTok.GetArchiveAsync(archiveId);

To delete an archive, you can call a OpenTokSDK.OpenTok instance's DeleteArchive(archiveId) method or call the OpenTokSDK.Archive instance's Delete() method.

// Delete an archive from an archive ID (fetched from database)
OpenTok.DeleteArchive(archiveId);

// Delete an archive from an Archive instance (returned from GetArchive)
Archive.Delete();

or

// Delete an archive from an archive ID (fetched from database)
OpenTok.DeleteArchiveAsync(archiveId);

// Delete an archive from an Archive instance (returned from GetArchive)
Archive.DeleteAsync();

You can also get a list of all the Archives you've created (up to 1000) with your API Key. This is done using an OpenTokSDK.OpenTok instance's ListArchives(int offset, int count) method. You may optionally paginate the Archives you receive using the offset and count parameters. This will return an OpenTokSDK.ArchiveList object.

// Get a list with the first 50 archives created by the API Key
var archives = OpenTok.ListArchives();
var archives = OpenTok.ListArchivesAsync();

// Get a list of the first 50 archives created by the API Key
var archives = OpenTok.ListArchives(0, 50);
var archives = OpenTok.ListArchivesAsync(0, 50);

// Get a list of the next 50 archives
var archives = OpenTok.ListArchives(50, 50);
var archives = OpenTok.ListArchivesAsync(50, 50);

// Get a list of the first 50 archives created for the given sessionId
var archives = OpenTok.ListArchives(sessionId:sessionId);
var archives = OpenTok.ListArchivesAsync(sessionId:sessionId);

Note that you can also create an automatically archived session, by passing in ArchiveMode.ALWAYS as the archiveMode parameter when you call the OpenTok.CreateSession() method (see "Creating Sessions," above).

Working with Streams

You can get information about a stream by calling the GetStream(sessionId, streamId) method of the OpenTok class.

Stream stream = OpenTok.GetStream(sessionId, streamId);

// Stream Properties
stream.Id; // string with the stream ID
stream.VideoType; // string with the video type
stream.Name; // string with the name
stream.LayoutClassList; // list with the layout class list

You can get information about all the streams in a session by calling the ListStreams(sessionId) method of the OpenTok class.

StreamList streamList = OpenTok.ListStreams(sessionId);

streamList.Count; // total count

Force Disconnecting

Your application server can disconnect a client from an OpenTok session by calling the ForceDisconnect(sessionId, connectionId) method of the OpenTok class.

// Force disconnect a client connection
OpenTok.ForceDisconnect(sessionId, connectionId);

Sending Signals

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.

The sessionId parameter is the session ID of the session.

The signalProperties parameter is an instance of the SignalProperties class where you can set the data paramter and the type parameter.

  • data (string) -- The data string for the signal. You can send a maximum of 8kB.
  • 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 '~'.

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.

string sessionId = "SESSIONID";
SignalProperties signalProperties = new SignalProperties("data", "type");
OpenTok.Signal(sessionId, signalProperties);

string connectionId = "CONNECTIONID";
OpenTok.Signal(sessionId, signalProperties, connectionId);

Working with live streaming broadcasts

You can start a live-streaming broadcast of an OpenTok Session using a OpenTokSDK.OpenTok instance's StartBroadcast(sessionId, hls, rtmpList, resolution, maxDuration, layout) method. This returns an OpenTokSDK.Broadcast instance.

Also see the documentation for the Opentok.StopBroadcast() and OpenTok.GetBroadcast() methods.

SIP

You can connect a SIP platform to an OpenTok session using the Opentok.Dial(sessionId, token, sipUri, options) or Opentok.DialAsync(sessionId, token, sipUri, options) method.

You can send DTMF digits to all participants an active OpenTok session, or to a specific client connected to that session, using the Opentok.PlayDTMF(sessionId, digits, connectionId) or Opentok.PlayDTMFAsync(sessionId, digits, connectionId) method.

Forcing clients in a session to disconnect or mute published audio

You can force a specific client to disconnect from an OpenTok session using the Opentok.ForceDisconnect(sessionId, connectionId) method.

You can force the publisher of a specific stream to stop publishing audio using the Opentok.ForceMuteStream(sessionId, stream) or Opentok.ForceMuteStreamAsync(sessionId, stream)method.

You can force the publisher of all streams in a session ((except for an optional list of streams) to stop publishing audio using the Opentok.ForceMuteAll(sessionId, excludedStreamIds) or Opentok.ForceMuteAllAsync(sessionId, excludedStreamIds) method. You can then disable the mute state of the session by calling the Opentok.DisableForceMute(sessionId) or Opentok.DisableForceMuteAsync(sessionId) method.

Experience Composer

You can start an Experience Composer render using the Opentok.StartRenderAsync() method:

string sessionId = "opentok-session-id";
string token = "token-for-opentok-session";
string url = "https://your-render-url/path/";
StartRenderRequest request = new StartRenderRequest(sessionId, token, url);
OpenTok.StartRenderAsync(request);

To stop a renderer, call the Opentok.StopRenderAsync() method.

To list renderers, call the Opentok.ListRendersAsync() method.

Working with Audio Connector

You can start an Audio Connector stream by calling the OpenTok.StartAudioConnectorAsync(AudioConnectorStartRequest request)method:

var webSocket = new AudioConnectorStartRequest.WebSocket(
    new Uri("wss://service.com/ws-endpoint"),
    new []{"streamId-1", "streamId-2"},
    new Dictionary<string, string>
    {
        {"X-CustomHeader-Key1", "headerValue1"},
        {"X-CustomHeader-Key2", "headerValue2"},
    });
var startRequest = new AudioConnectorStartRequest(sessionId, token, webSocket);
AudioConnector response = await this.OpenTok.StartAudioConnectorAsync(startRequest);

Changing the Timeout for HTTP Requests

If you would like to adjust the timeouts for Http Requests sent by the client SDK you can by calling OpenTok.SetDefaultRequestTimeout(int timeout) - note timeout is in milliseconds

this.OpenTok = new OpenTok(apiKey, apiSecret);
this.OpenTok.SetDefaultRequestTimeout(2000);

Samples

There are two sample applications included with the SDK. To get going as fast as possible, clone the whole repository and follow the Walkthroughs:

Documentation

Reference documentation is available at https://tokbox.com/developer/sdks/dot-net/reference/.

Requirements

You need an OpenTok API key and API secret, which you can obtain by logging into your Vonage Video API account.

The OpenTok .NET SDK requires .NET Framework 4.5.2 or greater.

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

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

Alternatively, if your application is dependent on a different version of TLS for other APIs, you can alternatively add TLS to the list of supported methods with a bitwise OR:

ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;

Release Notes

See the Releases page for details about each release.

Important changes since v2.2.0

Changes in v3.0.0:

This version requires .NET Framework 4.5.2 or greater.

Changes in v2.2.1:

The default setting for the CreateSession() method is to create a session with the media mode set to relayed. In previous versions of the SDK, the default setting was to use the OpenTok Media Router (media mode set to routed). In a relayed session, clients will attempt to send streams directly between each other (peer-to-peer); if clients cannot connect due to firewall restrictions, the session uses the OpenTok TURN server to relay audio-video streams.

Changes in v2.2.0:

This version of the SDK includes support for working with OpenTok archives.

This version of the SDK includes a number of improvements in the API design. These include a number of API changes:

  • New OpenTok class -- The name of the main class has changed from OpenTokSDK to OpenTok. In the previous version, the constructor was OpenTokSDK(). In v2.2, it is OpenTok(int apiKey, int apiSecret).

  • CreateSession -- In the previous version, there were two methods to create a session: OpenTokSDK.CreateSession(String location) and OpenTokSDK.CreateSession(String location, Dictionary<string, object> options). These methods returned a string (the session ID).

    In v2.2, the OpenTok class includes one method, which takes two parameters (both optional): CreateSession(string location = "", MediaMode mediaMode = MediaMode.ROUTED). The mediaMode parameter replaces the p2p.preference setting in the previous version. The method returns a Session Object.

  • GenerateToken -- In the previous version, there were two methods: OpenTokSDK.GenerateToken(string sessionId) and OpenTokSDK.GenerateToken(string sessionId, Dictionary<string, object> options) In v2.2, this is replaced with the following method: OpenTokSDK.OpenTok.GenerateToken(string sessionId, Role role = Role.PUBLISHER, double expireTime = 0, string data = null). All parameters, except the sessionId parameter, are optional.

    Also, the Session class includes a method for generating tokens: OpenTokSDK.Session.GenerateToken(Role role = Role.PUBLISHER, double expireTime = 0, string data = null).

Development and Contributing

Interested in contributing? We ❤️ pull requests! See the Development and Contribution guidelines.

Getting Help

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:

Further Reading

opentok-.net-sdk's People

Contributors

aiham avatar aoberoi avatar danikun avatar dlemstra avatar ggoldens avatar jeffswartz avatar jlew-cs avatar kayhuba avatar lucashuang0802 avatar matt-lethargic avatar michaeljolley avatar msach22 avatar nexmodev avatar onpoc avatar slorello89 avatar swhitley avatar tr00d avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opentok-.net-sdk's Issues

Xamarin Support on nuget

This library is fully compatible with Xamarin projects. Please update the nuget package to support Xamarin IOS and Android projects so we can import this project directly using nuget.... and not have to copy and paste the code into our project. manually...

testing: less than CLR 4.0?

right now both the travis and appveyor CI build configurations force CLR 4.0 or greater. the build fails with less versions but it might be something trivial.

A Better .Net Exprience

Hello,

I looked at this library and thought I would improve the user experience for .Net developers so I did the following in my repository.

  • Created a .Net Nuget package for .Net users
  • Created a Unit Testing Suite for .Net users
  • Got rid of dictionaries and just using anonymous objects instead.

Check it out.

https://github.com/khalidabuhakmeh/OpenTokApi

Now to go and try to do something with OpenTok.

Use create-session REST API that returns JSON data

There is a new version of the create-session REST API that returns JSON data when you include an "Accept: application/json" header in the request. If this is used the XML library dependency can be eliminated.

OpenTokWebException innerException

When an OpenTokWebException occurs and the constructor which uses an inner exception is used (e.g. in HttpClient's doRequset method), the innerException field isn't populated.

Standardize error handing

There needs to be a set of Error types defined and their meaning nailed down so that developers can predictably deal with error conditions.

This will also be subject to an internal API Review.

CreateSession exception

Hello everyone,
I'd like to know why this code is not ok. When i run it an exception is raised on CreateSession method.
The error is:

"Error with request submission"

I checked the apikey and secret key and they are ok.

This also happens with the demo solution.

Thanks in advance....

Here is the code:

Dim opentok As New OpenTok(API_KEY, API_SECRET)
Dim opentokSession As Session

    Try
        opentokSession = opentok.CreateSession(MediaMode.ROUTED)


        SESSIOID = opentokSession.Id
        ' Replace with meaningful metadata for the connection.
        Dim connectionMetadata As String = "username=Bob,userLevel=4"

        ' Generate a token. Use the Role value appropriate for the user.
        TOKEN = opentok.GenerateToken(SESSIOID, Role.PUBLISHER, Nothing, connectionMetadata)
    Catch ex As System.Exception
        Dim a As String

        a = ex.ToString

        'Catch ex As OpenTokException
        '    Dim a As String

        '    a = ex.ToString

    End Try

outputMode.ToString().ToLower() generates invalid data if called within Turkish Culture settings

var data = new Dictionary<string, object>() { { "sessionId", sessionId }, { "name", name }, { "hasVideo", hasVideo }, { "hasAudio", hasAudio }, { "outputMode", outputMode.ToString().ToLower() } };

Dear Opentok Developers,

We recently faced a very annoying issue where our StartArchive called resulted in a ""The request was aborted: The request was canceled." exception for clients in Turkey.

After multiple days of debugging we found out that it was not related with Turkey as a country rather Turkish being the preferred language in the browser of the affected clients.
It turned out that converting the enum "INDIVIDUAL" to lower case string usually results in a string "individual" - as expected - however when .NET is running with culture "tr-TR" the result of this operation is "ındıvıdual" (please not the "i" characters without a dot on top!). This is because in the Turkish language there are two different "i" character one with dot on top and one without both having there upper case versions. As a result converting the upper case latin i character (that has not dot on top) results in Turkish culture in a lower case "ı" character (i without a dot on top) that later provokes an exception ("Cannot close stream until all bytes are written.") being thrown at https://github.com/opentok/Opentok-.NET-SDK/blob/master/OpenTok/Util/HttpClient.cs#L147 upon stream.Write.

In our case the issue appeared because in our Web.config we had the following value:
<globalization uiCulture="auto" culture="auto" enableClientBasedCulture="true" />

As your SDK may be used in such environment I suggest to apply a fix that is straightforward and of very low risk in my opinion. The fix would be to change:
outputMode.ToString().ToLower()
to
outputMode.ToString().ToLowerInvariant()

That way the conversion will be independent of any application level culture settings and will always result the expected "individual" string.

Best Regards,


Laszlo Vass
Web developer
[email protected] | realeyesit.com

How does the scheduled meetings work?

If i want to schedule a group video conference in the future date then when does the session gets created or how to make sure all participants joins same session ? Is it that session will be created when a conference is scheduled but token will be generated when the users start joining the conference. Any sample code would be nice.

Request for Screensharing Application using .net Libraries

Hello There,
I am looking for a cross-platform solution that would capture the screen,
Encode(VP8) & stream desktop @ 1080p , 30 fps.May I please request for sample app on screensharing crossplatform desktop apps showing 30fps?

Also, does open tok SDK supports streaming of Audio on Android.

Thanks,
Raj

Feature: integration testing

sometimes just checking against canned responses (fixtures) is not good enough.

the main use case for integration testing is running the suite against the internal nightly build environment to detect problems (incompatible API changes, bad handling in the SDKs, etc) early.

one of the challenges in running integration tests is that many of the operations being tested require a specific state on the server. for example: starting an archive successfully requires that at least one client connection to the specific OpenTok session exists, deleting an archive requires an archive to exist, stopping an archive requires a started archive, etc.

one approach is to repurpose the unit tests to run in a different mode where they can hit live servers.

another approach could be scenario-driven, where a scripted set of operations are carried out sequentially. this could be better in address the challenge with server side state.

another technique that could be employed to address the server side state challenge is using a specific build of the client side opentok.js library that can run in node. the integration tests could "shell out" to a CLI that can conduct client side operations that will assist in setting up the proper state (like a client connection before starting an archive).

write unit tests and add AppVeyor/TeamCity support

make sure that the unit tests are using an API Key and Secret from some config (like environment variables) and the instructions to set this up is in the README.md

don't do integration tests (don't make network calls).

implement at the very least a common set of tests that are run across languages

output TAP?

http://www.appveyor.com/
http://teamcity.codebetter.com/
https://docs.google.com/spreadsheet/viewform?hl=en_US&formkey=dERWT1Nmc08tQ2RzV29aWElWdjg3amc6MQ#gid=0

Newtonsoft is out of date

Reported by a partner:

It would appear that our SDK is using an older version of Newtonsoft.Json. We need to update it to the later version: 6.0.3 -> 10.0.1

HelloWorld Sample does not work in 2 windows

Hi
I'm having a problem with the HelloWorld sample, when I open more than one window, the others do not load the new frame. I had this problem developing a personal project and the same happened with the sample taken here.

capturar

Can anybody help me?
Thanks!

readme typo, generatetoken signature

"You can generate a token either by calling an OpenTokSDK.OpenTok instance's GenerateToken(string sessionId, Role role, double expireTime, double data) method, or by calling a OpenTokSDK.Session instance's GenerateToken(Role role, double expireTime, double data) method after creating it."

data should be a string

organize unit tests better

there's only one test Class right now: OpenTokTest. There should be another one to test the API for Archives named ArchiveTest, and possibly even ArchiveListTest. it should be as DRY as possible so the common method tests should ideally only be implemented once.

Options compatibility problem

I'm not sure how this posting should be formatted so forgive the informality.

ISSUE:
The "CreateTime" option in the GenerateToken method should be changed to "create_time".
The way the code is currently breaks the API.

OpenTokException does not expose InnerException

We have intermittent errors scheduling interviews with OpenTok and all we see is "Error with request submission". Is there a reason the exception parameter is not passed to System.Exception as the InnerException? It would be helpful to debug intermittent errors.

proxy support

feature request from opentok-node, probably applies here too

Easily switch from debug to Release

If you want to automatically switch from staging to production. Change the OpenTok CreateSession function to the following:

        NameValueCollection appSettings = ConfigurationManager.AppSettings;

if DEBUG

              String opentok_server   = appSettings["opentok_server_staging"];

else

             String opentok_server   = appSettings["opentok_server_production"];

endif

        options.Add("location", location);
        options.Add("partner_id", appSettings["opentok_key"]);

        XmlDocument xmlDoc = CreateSessionId(string.Format("{0}/session/create", opentok_server), options);

When you build for release, the correct server will be selected. Same is true when you are in debug mode.

The JavaScript can be done the same way. Just place a literal tag where the javascript should be on the aspx page and on the code behind pass the correct JavaScript using the logic above.

Great work on the class

InvalidFormatException when using GenerateToken

Opentok.CreateSession validates that the sessionId is indeed a sessionId. If the sessionId doesn't have the right format, an OpentokException should be thrown. Apparently some correct sessionIds trigger the OpentokException.

add auto archived sessions support

API:

// Auto-archived session
            var session = OpenTok.CreateSession(archiveMode: ArchiveMode.ALWAYS); // impled mediaMode: MediaMode.ROUTED (otherwise throw error)

API Proposal: Broadcasts with Layout

This is a request for comments regarding the API for upcoming platform functionality. The platform functionality is not generally available at the moment and there is no guarantee it will be released in any form.

this is related to #66

Broadcasts

Create a Broadcast

// each returns an instance of `Broadcast`

// simplest case (`sessionId` is a String)
var broadcast = opentok.StartBroadcast(sessionId);

// using predefined layout (`Layout.PIP` is an instance of `Layout` and a static property of the `Layout` class)
var broadcast = opentok.StartBroadcast(sessionId, layout=Layout.PIP);

// using a custom layout (`Layout.CreateCustom()` returns an instance of `Layout`, `stylesheet` is a CSS string)
var broadcast = opentok.StartBroadcast(sessionId, layout=Layout.CreateCustom(stylesheet=stylesheet));

Stop a Broadcast

// when you don't have a `Broadcast` instance (`broadcastId` is a String)
var broadcast = opentok.StopBroadcast(broadcastId);

broadcast.Stop();

Get a Broadcast

// `broadcastId` is a String
var broadcast = opentok.GetBroadcast(broadcastId);

// `Broadcast` has the following properties
broadcast.Id; // string
broadcast.SessionId; // string
broadcast.CreatedAt; // long
broadcast.UpdatedAt; // long
broadcast.PartnerId; // string
broadcast.Urls; // Dictionary<string, string> contains a key `"HLS"` with a value of a URL

Get a Broadcast Layout

// each returns a Layout instance

// when you don't have a `Broadcast` instance (`broadcastId` is a String)
var layout = opentok.GetBroadcastLayout(broadcastId);

var layout = broadcast.GetLayout()

Update a Broadcast Layout

// when you don't have a `Broadcast` instance (`broadcastId` is a String, `layout` is an instance of `Layout`)
opentok.UpdateBroadcastLayout(broadcastId, layout);

// `layout` is an instance of `Layout`
broadcast.UpdateLayout(layout);

Update a Stream's Layout Class List

Question: should we have an API for updating multiple streams?
Question: should these return a representation of the Stream properties?

// when you don't have a `Session` instance
opentok.UpdateStream(sessionId, streamId, layoutClassList=new string[] { "class1" });

session.UpdateStream(streamId, layoutClassList=new string[] { "class1", "class2" });

archiving sample: json serialization

when an Archive object is returned, the status field is serialized to an integer. it would be better and more self-descriptive to serialize to a string. look into Content Negotiation in Nancy. the JsonProcessor class is used to do the serialization.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.