Comparing version 0.2.2 to 0.3.0
@@ -15,7 +15,2 @@ var http = require('http') | ||
// set the tokbox host, for dev: staging.tokbox.com, for prod: api.opentok.com | ||
// it defaults to staging.tokbox.com, so you only need to set it in prod: | ||
// | ||
// ot.setEnvironment("staging.tokbox.com") | ||
server = http.createServer(function(req, res){ | ||
@@ -64,3 +59,3 @@ var path = url.parse(req.url).pathname; | ||
'<title>OpenTok Hello World</title>\n', | ||
'<script src="http://staging.tokbox.com/v0.91/js/TB.min.js"></script>\n', | ||
'<script src="http://static.opentok.com/v0.91/js/TB.min.js"></script>\n', | ||
'<script>\n', | ||
@@ -67,0 +62,0 @@ 'var apikey = "',apikey,'"\n', |
@@ -7,4 +7,3 @@ var https = require('https') | ||
, TOKEN_SENTINEL = "T1==" | ||
, STAGING_HOST = "staging.tokbox.com" | ||
, PROD_HOST = "api.opentok.com" | ||
, API_HOST = "api.opentok.com" | ||
, SESSION_API_ENDPOINT = "/hl/session/create" | ||
@@ -26,25 +25,8 @@ , GET_MANIFEST = "/archive/getmanifest/" | ||
// OpenTokSDK constructor | ||
var OpenTokSDK = exports.OpenTokSDK = function(partnerId, partnerSecret, properties){ | ||
var OpenTokSDK = exports.OpenTokSDK = function(partnerId, partnerSecret){ | ||
this.partnerId = partnerId | ||
this.partnerSecret = partnerSecret | ||
this.api_url = STAGING_HOST; | ||
if(properties && properties['API_URL']){ | ||
if(properties['API_URL'].split('staging').length > 1){ | ||
// This is meant to guart against http://staging.tokbox.com vs staging.tokbox.com vs https... | ||
this.api_url = STAGING_HOST; | ||
}else{ | ||
this.api_url = PROD_HOST; | ||
} | ||
} | ||
this.api_url = API_HOST; | ||
} | ||
OpenTokSDK.prototype.setEnvironment = function(host){ | ||
if(host.split('staging').length >1 ){ | ||
this.api_url = STAGING_HOST | ||
}else{ | ||
this.api_url = PROD_HOST | ||
} | ||
} | ||
OpenTokSDK.OpenTokArchive = function(sdkObject){ | ||
@@ -86,2 +68,5 @@ var self = this; | ||
}; | ||
OpenTokSDK.prototype.getArchiveManifest = function(archiveId, token, callback){ | ||
this.get_archive_manifest( archiveId, token, callback ); | ||
} | ||
@@ -88,0 +73,0 @@ OpenTokSDK.prototype.get_archive_manifest = function(archiveId, token, callback){ |
{ | ||
"name": "opentok", | ||
"description": "OpenTokSDK for node.js", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"homepage": "https://github.com/bsstoner/opentok", | ||
@@ -6,0 +6,0 @@ "repository": "https://github.com/bsstoner/opentok.git", |
@@ -5,3 +5,3 @@ # OpenTokSDK for Node.js | ||
This is the official OpenTok NodeJS Module. | ||
This is the OpenTok NodeJS Module. | ||
@@ -24,3 +24,3 @@ ## Installation | ||
Request your API key and API secret at <http://www.tokbox.com/opentok/api/tools/js/apikey>. You can use the staging environment for development. This package uses this staging environment by default. | ||
Request your API key and API secret at <http://www.tokbox.com/opentok/api/tools/js/apikey>. | ||
@@ -30,6 +30,4 @@ ### OpenTokSDK | ||
In order to use any of the server side functions, you must first create an `OpenTokSDK` object with your developer credentials. | ||
You must pass in your *API key* and *API secret*. If your app is in production, you must also pass in a object containing the `API_URL` property. | ||
For more information about production apps, check out <http://www.tokbox.com/opentok/api/tools/documentation/overview/production.html#launching>. | ||
You must pass in your *API key* and *API secret*. | ||
Example: ( Staging ) | ||
<pre> | ||
@@ -41,10 +39,5 @@ var key = ''; // Replace with your API key | ||
Example: ( Production ) | ||
<pre> | ||
var opentok = new OpenTok.OpenTokSDK(key, secret, {API_URL:'https://api.opentok.com/hl'}); | ||
</pre> | ||
### Creating Sessions | ||
Use your `OpenTokSDK` object to create a `session_id`. See <http://www.tokbox.com/opentok/api/tools/documentation/api/server_side_libraries.html#create_session> for more details. | ||
`create_session` takes 2-3 parameters: | ||
`createSession` takes 2-3 parameters: | ||
> location [string] - give Opentok a hint on where you are running your application by specifiying an IP (e.g. '127.0.0.1') | ||
@@ -58,4 +51,5 @@ > properties [object] - OPTIONAL. Set peer to peer as `enabled` or `disabled` | ||
var sessionId = ''; | ||
opentok.create_session(location, function(result){ | ||
opentok.createSession(location, function(result){ | ||
sessionId = result; | ||
// Do things with sessionId | ||
}); | ||
@@ -68,3 +62,3 @@ </pre> | ||
var sessionId = ''; | ||
opentok.create_session(location, {'p2p.preference':'enabled'}, function(result){ | ||
opentok.createSession(location, {'p2p.preference':'enabled'}, function(result){ | ||
sessionId = result; | ||
@@ -76,3 +70,3 @@ }); | ||
With the generated session_id and an OpenTokSDK object, you can start generating tokens for each user. See <http://www.tokbox.com/opentok/api/tools/documentation/api/server_side_libraries.html#generate_token> for more details. | ||
`generate_token` takes in an object with 1-4 properties, and RETURNS a token as a string: | ||
`generateToken` takes in an object with 1-4 properties, and RETURNS a token as a string: | ||
> session_id [string] - REQUIRED. This token is tied to the session it is generated with | ||
@@ -85,3 +79,3 @@ > role [string] - OPTIONAL. opentok.RoleConstants.{SUBSCRIBER|PUBLISHER|MODERATOR}. Publisher role used when omitted. | ||
<pre> | ||
var token = opentok.generate_token({session_id:session_id, role:OpenTok.RoleConstants.PUBLISHER, connection_data:"userId:42"}); | ||
var token = opentok.generateToken({session_id:session_id, role:OpenTok.RoleConstants.PUBLISHER, connection_data:"userId:42"}); | ||
</pre> | ||
@@ -101,3 +95,3 @@ | ||
With your **moderator token** and a OpenTokSDK object, you can generate a OpenTokArchive object, which contains information for all videos in the Archive | ||
`OpenTokSDK.get_archive_manifest()` takes in 3 parameters: **archiveId** and **moderator token**, and a callback function | ||
`OpenTokSDK.getArchiveManifest()` takes in 3 parameters: **archiveId** and **moderator token**, and a callback function | ||
> archive_id [string] - REQUIRED. Get this from the client that created the archive. | ||
@@ -112,3 +106,3 @@ > token [string] - REQUIRED. Get this from the client or the generate_token method. | ||
opentok.get_archive_manifest(archiveId, token, function(tbarchive){ | ||
opentok.getArchiveManifest(archiveId, token, function(tbarchive){ | ||
var otArchive = tbarchive; | ||
@@ -123,3 +117,3 @@ }); | ||
<pre> | ||
opentok.get_archive_manifest(archiveId, token, function(tbarchive){ | ||
opentok.getArchiveManifest(archiveId, token, function(tbarchive){ | ||
var vidID = tbarchive.resources[0].getId(); | ||
@@ -126,0 +120,0 @@ }); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20325
288
136