Download full document:

Namespace: receiver

receiver

citrix.receiver

Members

(readonly) apiVersion

Properties:

Name Type Description
apiVersion String Workspace app for HTML5 API version.

Methods

(static) createSession(idopt, connectionParams, onSessionCreated)

Creates a new session and returns session instance through callback. Use session instance to start the session, register and handle events and to disconnect the session.

Parameters

Name Type Attributes Description
id string <optional> ID that is assigned when the session is created
connectionParams connectionParams Configuration options to create the session
onSessionCreated onSessionCreated Callback containing the session object created. Signature sample below:
function <function_name>(session_object){...}

Throws:

Unable to create session object.

Type
        ReceiverError

Example

Following code launches an app/desktop in an iframe. Setting preferences to hide the in-session toolbar.

try{
    citrix.receiver.setPath("http://html5client_hosted_url/");
    var id = "session1"; //Optional parameter
    var connectionParams = {
            "launchType" : "embed",
            "container" : {
                "type" : "iframe",
                "value" : "sessionIframe"
            },
            "preferences" : {
                "ui" : {
                    "toolbar" : {
                        "menubar" : false
                    }
                }
            }
        };
    function sessionCreated(sessionObject){

        //Handle session interactions like events, start, disconnect here.              
        // Adding onConnection event handler
        function connectionHandler(event){
            console.log("Event Received : " + event.type);
            console.log(event.data);        
        }               
        sessionObject.addListener("onConnection",connectionHandler);
        // Adding onConnectionClosed event handler
        function connectionClosedHandler(event){
            console.log("Event Received : " + event.type);      
            console.log(event.data);        
        }
        sessionObject.addListener("onConnectionClosed",connectionClosedHandler);

        // Adding onError event handler
        function onErrorHandler(event){
            console.log("Event Received : " + event.type);      
            console.log(event.data);
        }
        sessionObject.addListener("onError",onErrorHandler);

        //Adding onURLRedirection event handler
        function onURLRedirectionHandler(event){
            console.log("Event Received : " + event.type);      
            console.log(event.data);
        }
        sessionObject.addListener("onURLRedirection",onURLRedirectionHandler);

        //ICADATA has been constructed for example. Recommending to use StoreFront/WebInterface SDK to get ICA. 
        //Refer session.start() for more details.
        var icaData = {
            "Domain":"abcd",
            "ClearPassword":"xxxxxxxxx",
            "InitialProgram":"#Desktop",
            "Title":"Desktop",
            "Address":"xx.xx.xx.xx",
            "Username":"xyz"                
        };
        var launchData = {"type" :"json",value :icaData};   
        sessionObject.start(launchData);
    }
    citrix.receiver.createSession(id,connectionParams,sessionCreated);
}catch(ex){
    console.log(ex);
}

Methods

(static) setPath(path) {#.setPath .name}

Sets the HTML5Engine Path. Must be set before creating a session.

Parameters:

Name Type Description
path string Path of HTML5Client folder.

Throws:

Path is empty.

Type
        ReceiverError

(static) viewLog() {#.viewLog .name}

Opens the logging page in a new tab.HTML5Engine Path should be set before calling this API.

Throws:

HTML5 Engine Path is not set.

Type
        ReceiverError