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
            S_OFFLINE = 0;
            S_CONNECTING = 1;
            S_PAUSING = 2;
            S_ONLINE = 3; 
            
            //SitePhone.CallStatus flags
            CS_UNPLACED = 0;
            CS_ROUTING = 1;
            CS_EARLY_MEDIA = 2;
            CS_FAILED = 3;
            CS_RINGING = 4;
            CS_IN_PROGRESS = 5;
            CS_ON_HOLD = 6;
            CS_FINISHED = 7;
            CS_MISSED = 8;
            CS_REFUSED = 9;
            CS_BUSY = 10;
            CS_CANCELLED = 11;
            CS_LOCAL_HOLD = 12;
            CS_REMOTE_HOLD = 13;
            CS_VOICEMAIL_BUFFERING_GREETING = 14;
            CS_VOICEMAIL_PLAYING_GREETING = 15;
            CS_VOICEMAIL_RECORDING = 16;
            CS_VOICEMAIL_UPLOADING = 17;
            CS_VOICEMAIL_SENT = 18;
            CS_VOICEMAIL_CANCELLED = 19;
            CS_VOICEMAIL_FAILED = 20;
            CS_TRANSFERRING = 21;
            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.CallAllowed(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