opentok/Opentok-.NET-SDK — Issue #1: Easleasilyy switch from debug to Release
Author: TimBarton
Created: 2011-12-17 04:37:33+00:00
State: open

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