PlainHtml Content

Ask questions about the JavaScript API here

PlainHtml Content

Postby bharadwaj » Sat Nov 03, 2012 1:03 am

Hey OpenTok,
I am Taking a plain html and generating session and token from opentok server side libraries and passing these three values as static content to html.

But Session is connected and sessionConnectedHandler(event) is not firing and showing the message dialog.
The Connection timeout. Make Sure that You have allowed this page in FlashPlayer Global Settings Manager.
Goto:http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html

But i have added my file location and started my browser even then same error;
Please get me out of it:
Here is my code,

<html>
<head>


<script src="http://static.opentok.com/v0.91/js/TB.min.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript" language="javascript">

var tokenGen ="T1==cGFydG5lcl9pZD0yMTMwODc0MSZzZGtfdmVyc2lvbj10YmRvdG5ldCZzaWc9ZGJhYTRmYWFkNWM0Y2I5YTQ4YTIzM2JjZjc2YTM3YmIwYTMzMmJjODpjb25uZWN0aW9uX2RhdGE9NTA0JnNlc3Npb25faWQ9Ml9NWDR5TVRNd09EYzBNWDR4TUM0eE1DNHhNQzR6TjM1R2Nta2dUbTkySURBeUlESXpPalV4T2pVNElGQkVWQ0F5TURFeWZqQXVNRGMwTnpRNU1qbC0mY3JlYXRlX3RpbWU9MTM1MTkyNTY2MyZub25jZT0xMDE4OTEmcm9sZT1wdWJsaXNoZXI=";

var apiKey =21308741;

var sessionId = "2_MX4yMTMwODc0MX4xMC4xMC4xMC4zN35GcmkgTm92IDAyIDIzOjUxOjU4IFBEVCAyMDEyfjAuMDc0NzQ5Mjl-";
var VIDEO_WIDTH = 310;
var VIDEO_HEIGHT = 200;
var VIDEO_WIDTH1 = 310;
var VIDEO_HEIGHT1 = 400;
var publisher;
var session;
var subscribers = {};
var txt="";

function StartConference() {

alert("Conf Started");



TB.setLogLevel(TB.DEBUG);
TB.addEventListener("exception", exceptionHandler);


if (TB.checkSystemRequirements() != TB.HAS_REQUIREMENTS) {
alert("Please upgrade to the latest version of Flash.");
} else {
connect();


}



}

//To start the connecation
function connect() {

alert("connect called");
session = TB.initSession(sessionId); // Initialize session
alert("session intiialized");
// Add event listeners to the session
session.addEventListener('sessionConnected', sessionConnectedHandler);
session.addEventListener('streamCreated', streamCreatedHandler);
session.addEventListener('connectionCreated', connectionCreatedHandler);
session.addEventListener('sessionDisconnected', sessionDisconnectedHandler);
session.addEventListener('connectionDestroyed', connectionDestroyedHandler);
session.addEventListener('streamDestroyed', streamDestroyedHandler);

session.connect(apiKey, tokenGen);
alert("session connected");

}



//To disconnection the session
function leaveConference() {

session.disconnect();


}



//To start publishing our video
function startPublishing() {
if (!publisher) {
alert("publishing my video started");
var parentDiv = document.getElementById('myCamera');
// Create a div for the publisher to replace
var publisherDiv = document.createElement('div');
publisherDiv.setAttribute('id', 'opentok_publisher');
parentDiv.appendChild(publisherDiv);
var publisherProps = { width: VIDEO_WIDTH, height: VIDEO_HEIGHT };
// Pass the replacement div id and properties
publisher = TB.initPublisher(apiKey, publisherDiv.id, publisherProps);
session.publish(publisher);
alert("publishing my video finished");

}


}


//This is Our Video
function sessionConnectedHandler(event) {
alert("fired");
alert(event.streams.length+"My Stream");
startPublishing();

for (var i = 0; i < event.streams.length; i++) {
subscribeToStreams(event.streams[i]);
}


}

//New Arrived Streams
function streamCreatedHandler(event) {
alert(event.streams.length+"Other Streams");
startPublishing();

for (var i = 0; i < event.streams.length; i++) {
subscribeToStreams(event.streams[i]);
}

// Subscribe to any new streams that are created



}

function streamDestroyedHandler(event) {
// This signals that a stream was destroyed. Any Subscribers will automatically be removed.
// This default behaviour can be prevented using event.preventDefault()
}

//
function sessionDisconnectedHandler(event) {

// will automatically be removed. This default behaviour can be prevented using event.preventDefault()
publisher = null;



window.top.location = "Meeting.aspx";
}

function connectionDestroyedHandler(event) {
// This signals that connections were destroyed
}

function connectionCreatedHandler(event) {
// This signals new connections have been created.
}


//Streams of that session
function subscribeToStreams(stream) {

alert(event.streams.length);
if (stream.connection.connectionId == session.connection.connectionId) {
return;
}

var subscriberDiv = document.createElement('div'); // Create a div for the subscriber to replace
subscriberDiv.setAttribute('id', stream.streamId); // Give the replacement div the id of the stream as its id.
document.getElementById("subscribers").appendChild(subscriberDiv);
var subscriberProps = {height: VIDEO_HEIGHT1, width: VIDEO_WIDTH1 };
//subscribers[stream.streamId] =
session.subscribe(stream, subscriberDiv.id, subscriberProps);



}

//Exception Handler

function exceptionHandler(event) {
// Retry session connect
if (event.code === 1006 || event.code === 1008 || event.code === 1014) {
alert('There was an error connecting. Trying again.');
session.connect(apiKey, tokenGen);
}
}


//To Show and Hide the controls..

function show(id) {
document.getElementById(id).style.display = 'block';
}

function hide(id) {
document.getElementById(id).style.display = 'none';
}




</script>

</head>

<body onload="StartConference();">

<div class="span-17half last">
<div class="span-8 last" id="myCamera" style="float: left;border:1px solid #999999;"></div>
<div class="span-8 last" id="subscribers" style="float: left;border:1px solid #999999;margin-left:10px;"></div>
</div>

</body>



</html>



Was this post helpful? (0)
bharadwaj
 
Posts: 6
Joined: Mon Oct 08, 2012 7:30 am
Thumbs Up: 1

Re: PlainHtml Content

Postby jtsai » Mon Nov 05, 2012 1:56 pm

Hi

Is this page all green for you? http://tokbox.com/user-diagnostic/

John
Was this post helpful? (0)
User avatar
jtsai
 
Posts: 4541
Joined: Wed Sep 14, 2011 3:00 pm
Thumbs Up: 195

Re: PlainHtml Content

Postby simran » Thu Nov 15, 2012 2:26 pm

Hi,
I am experiencing this same issue. I clicked on the link above to troubleshoot and it tells me that it could not connect to port 443. So I looked up how to open up the port on windows 7 (my OS) and I found a few ways to test if 443 was in fact open. According to the test Microsoft provides on their support site, port 443 is open in my OS. Am I missing something? Could the troubleshooter be wrong? Have you seen an error like this before? Any suggestions? I've hit a roadblock here and I am really excited to try this out...
Thanks!
Was this post helpful? (0)
simran
 
Posts: 2
Joined: Thu Nov 15, 2012 1:49 pm
Thumbs Up: 0

Re: PlainHtml Content

Postby mumm » Thu Nov 15, 2012 4:17 pm

Hey Simran,

Could you try running the demo from a webserver (either a remote or local one) instead of running it straight from the filesystem? I suspect your port 443 is open, and the diagnostic tool is showing it correctly, but Flash when it is running from the filesystem is not able to.

Jon
Was this post helpful? (0)
mumm
 
Posts: 392
Joined: Wed May 18, 2011 12:10 am
Thumbs Up: 29

Re: PlainHtml Content

Postby simran » Mon Nov 19, 2012 9:49 am

Thanks!
That was my problem.
Was this post helpful? (0)
simran
 
Posts: 2
Joined: Thu Nov 15, 2012 1:49 pm
Thumbs Up: 0


Return to JavaScript



Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron