ooVoo Forums

Welcome to ooVoo Forums Sign in | Join | Help
in Search

code for oovoo auto reconnect

Last post 08-10-2009 3:27 PM by h2ofun. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 07-20-2009 5:22 PM

    • h2ofun
    • Top 50 Contributor
    • Joined on 06-01-2009
    • Posts 8

    code for oovoo auto reconnect

     Trying to see if anyone has written some code that will do auto reconnect of oovoo?

    I will be in a video room, and my connection into room drops, and I need to refresh the browser to get

    back in.  Would be great to have code running that could sense these conditions automatically, and

    then refresh the browser for the reconnection.

     

    Thanks

     

    Dave

  • 08-10-2009 9:29 AM In reply to

    Re: code for oovoo auto reconnect

    Hi Dave,

    Here is the code to get what you want working.
    Just remeber to change the URL to some page on the same domain the oovoo room is hosted on.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >

    <head>

    <title>ooVoo Video Chat Room</title>

    <script type="text/javascript" src="http://videocallroom.oovoo.com/oovoomelink/codelib/oovoorooms.js"></script>

    <script type="text/javascript" src='http://java.com/js/deployJava.js'></script>

    </head>

    <body>

    <script type="text/javascript" id="TestInternetConnection" >

    var URL = "http://shay/";

    var CheckInterval = 5000;

     

    var req;

    function processReqChange() {

    // only if req shows "loaded"

    if (req.readyState == 4) {//alert (req.responseText);

    // only if "OK"

    if (req.status == 200) {

    // OK

    //alert ("OK");

    myRoom=EnterRoom('oovooRoom');

    } else {

    // FAILED

    //alert("There was a problem retrieving the XML data:\n" + req.statusText);

    setTimeout("CheckConnection()", CheckInterval);

    }

    }

    }

    function CheckConnection() {

    req = false;

    // branch for native XMLHttpRequest object

    if(window.XMLHttpRequest && !(window.ActiveXObject)) {

    try {

    req = new XMLHttpRequest();

    } catch(e) {

    req = false;

    }

    // branch for IE/Windows ActiveX version

    } else if(window.ActiveXObject) {

    try {

    req = new ActiveXObject("Msxml2.XMLHTTP");

    } catch(e) {

    try {

    req = new ActiveXObject("Microsoft.XMLHTTP");

    } catch(e) {

    req = false;

    }

    }

    }

    if(req) {

    req.onreadystatechange = processReqChange;

    req.open("GET", URL, true);

    req.send("");

    }

    }

    function EndOfCall(duration)

    {

    myRoom = null;

    document.getElementById("oovooRoom").innerHTML = "ooVoo video call is currently offline - trying to reconnect";

    setTimeout("CheckConnection();",2000);

    }

    function CallStateChanged(state)

    {

    if (state == 14)

    {

    EndOfCall(-1);

    }

    }

    </script>

    <div id="oovooRoom" ></div>

    <script type="text/javascript">

    // partner should put his ID here instead of this sample ID

    roomProps.roomID = '6A6807E2C67C30F2E04400144F7E6014'; //production?

    //roomProps.roomID = '6FD75B981E881D84E044001636E91FD0'; // QA

    roomProps.instanceKey = '{D58D34FE-05C0-4ff1-9D46-217DCABDA04A}';

    roomProps.width = '795';

    roomProps.height = '640';

    roomProps.backgroundColor = '#666666';

    roomProps.captionColor = '#FFFFFF';

    roomProps.captionText = 'ooVoo Video Chat Room';

    // Set the name of joined participant

    roomProps.displayName = "TEST";

    var myRoom=EnterRoom("oovooRoom");

    </script>

     

    </body>

    </html>

    Regards,
    Shay.

  • 08-10-2009 3:27 PM In reply to

    • h2ofun
    • Top 50 Contributor
    • Joined on 06-01-2009
    • Posts 8

    Re: code for oovoo auto reconnect

     Shay, great code.  I added a few comments, and the ability to trigger the same function if the room is full via your inputs.

     

    // The EndOfCall function is used to reconnect the call when all conditions are cleared.
        // This can be called from an end of call, or the internet connection dropping and giving an error,
        // or an error that the video room is full.
        function EndOfCall(duration)
        {
            myRoom = null;
            document.getElementById("oovooRoom").innerHTML = "ooVoo video call is currently offline - trying to reconnect";
            setTimeout("CheckConnection();",2000);
        }
        //The CallStateChanged function is checking to see if the internet state as changed, like it was dropped.  If so, the function,
        // EndOfCall is called.  This state is 14.
        function CallStateChanged(state)
        {
            if (state == 14)
            {
                EndOfCall(-1);
            }
        }
        //The CallStateChanged function is checking to see if the video room is full. If so, the function,
        // EndOfCall is called.  This state is 2.  Instead of the EndOfCall being called, a branch to another webpage
        //with streaming cameras going might be another possibility.
        function CallStateChanged(state)
        {
            if (state == 2)
            {
                EndOfCall(-1);
            }
        }
     

Page 1 of 1 (3 items)