SitePhone Object



 
The SitePhone object controls the environment of the Voice over IP plugin.


Members Table

Remarks
    This object is available through the collection Plugins. Use the SitePhone object to manage calls and short messages.

    Note that the path of a file using SiteKiosk objects must be allowed in the
    SiteKiosk configuration (Security -> Access -> URL's With Script Permission)
    if it is not a browser skin file.
Examples
    The following example shows information about the core features of the Voice over IP plugin.

    <!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>SitePhone</title>
        <script type="text/javascript">
            window.external.InitScriptInterface();
            SitePhone = SiteKiosk.Plugins("SitePhone");
            
            //SitePhone.State flags
            var S_OFFLINE = 0;
            var S_CONNECTING = 1;
            var S_PAUSING = 2;
            var S_ONLINE = 3; 
            
            //SitePhone.CallStatus flags
            var CS_UNPLACED = 0;
            var CS_ROUTING = 1;
            var CS_EARLY_MEDIA = 2;
            var CS_FAILED = 3;
            var CS_RINGING = 4;
            var CS_IN_PROGRESS = 5;
            var CS_ON_HOLD = 6;
            var CS_FINISHED = 7;
            var CS_MISSED = 8;
            var CS_REFUSED = 9;
            var CS_BUSY = 10;
            var CS_CANCELLED = 11;
            var CS_LOCAL_HOLD = 12;
            var CS_REMOTE_HOLD = 13;
            var CS_VOICEMAIL_BUFFERING_GREETING = 14;
            var CS_VOICEMAIL_PLAYING_GREETING = 15;
            var CS_VOICEMAIL_RECORDING = 16;
            var CS_VOICEMAIL_UPLOADING = 17;
            var CS_VOICEMAIL_SENT = 18;
            var CS_VOICEMAIL_CANCELLED = 19;
            var CS_VOICEMAIL_FAILED = 20;
            var CS_TRANSFERRING = 21;
            var CS_TRANSFERRED = 22; 
            
            function OnBodyLoad()
            {
                //Initialize events
                SitePhone.OnStateChanged = OnStateChanged;
                SitePhone.OnCallStateChanged = OnCallStateChanged;
                SitePhone.OnCallDurationChanged = OnCallDurationChanged;
                OnStateChanged();
                OnCallStateChanged();
                OnCallDurationChanged();
            }
            
            function OnStateChanged()
            {
                switch (SitePhone.State)
                {
                    case S_OFFLINE:
                        StateDiv.innerHTML = "Offline";
                        break;
                    case S_CONNECTING:
                        StateDiv.innerHTML = "Connecting";
                        break;
                    case S_PAUSING:
                        StateDiv.innerHTML = "Pausing";
                        break;
                    case S_ONLINE:
                        StateDiv.innerHTML = "Online";
                        break;
                    default:
                        StateDiv.innerHTML = "Unknown";
                }
                
                switch (SitePhone.State)
                {
                    case S_ONLINE:
                        CallBtn.disabled = false;
                        break;
                    default:
                        CallBtn.disabled = true;
                }
            }
            
            function OnCallStateChanged()
            {
                switch (SitePhone.CallStatus)
                {
                    case CS_ON_HOLD:
                    case CS_LOCAL_HOLD:
                    case CS_REMOTE_HOLD:
                        CallStatusDiv.innerHTML = "Call on hold";
                        break;
                    case CS_ROUTING:
                        CallStatusDiv.innerHTML = "Connecting...";
                        break;
                    case CS_RINGING:
                        CallStatusDiv.innerHTML = "Ringing...";
                        break;
                    case CS_IN_PROGRESS:
                        CallStatusDiv.innerHTML = "Call in progress";
                    case CS_FINISHED:
                        CallStatusDiv.innerHTML = "Call finished";
                        break;
                    case CS_FAILED:
                    case CS_REFUSED:
                    case CS_MISSED:
                        CallStatusDiv.innerHTML = "Connection problem";
                        break;
                }
                
                switch (SitePhone.CallStatus)
                {
                    case CS_IN_PROGRESS:
                    case CS_ON_HOLD:
                    case CS_LOCAL_HOLD:
                    case CS_REMOTE_HOLD:
                        FinishCallBtn.disabled = false;
                        break;
                    default:
                        FinishCallBtn.disabled = true;
                }
            }
            
            function OnCallDurationChanged()
            {
                CallDurationDiv.innerHTML = SitePhone.CallDuration;
            }
            
            function OnCallBtnClick()
            {
                try
                {
                    destination = DestinationTb.value;
                    if (SitePhone.IsCalleeAllowed(destination))
                        SitePhone.StartCall(destination);
                }
                catch(e){}
            }
            
            function OnFinishCallBtnClick()
            {
                SitePhone.FinishCall();
            }
        </script>
    </head>
    <body onload="OnBodyLoad();">
        <div id="StateDiv"></div>
        <div id="CallStatusDiv"></div>
        <div id="CallDurationDiv"></div>
        <input id="DestinationTb" type="text" />
        <input id="CallBtn" type="button" value="Call"
            onclick="OnCallBtnClick();" disabled="disabled" />
        <input id="FinishCallBtn" type="button" value="Hang Up"
            onclick="OnFinishCallBtnClick();" disabled="disabled" />
    </body>
    </html>
    

Applies to
    SiteKiosk v7.0 (and later versions).

Back to top