Citrix Workspace app for Chrome HDX SDK

Namespace: receiver

receiver

citrix.receiver

Members

(readonly) apiVersion

Properties

Name Type Description
apiVersion String HDX SDK for Chrome version.

Methods

(static) createSession(id, connectionParams, onSessionCreated)

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

Parameters

Name Type Description
id string Workspace app for Chrome ID. For example, the id of the store version is haiffjcadagjlijoggckpgfnoeiflnem.
connectionParams connectionParams Configuration options to create the session.
onSessionCreated onSessionCreated Callback containing the session object created. Signature sample: function <function_name>(session_object){…}

Throws

Unable to create session object.

Type

ReceiverError

Examples

Example 1: This example launches an app/desktop in a new window (similar to the session launch using Workspace app for Chrome).

//Use appropriate citrix receiver id. This sample uses store version.
//EAR = lbfgjakkeeccemhonnolnmglmfmccaag , store version = haiffjcadagjlijoggckpgfnoeiflnem
var citrixReceiverId = "haiffjcadagjlijoggckpgfnoeiflnem";

try{
    var connectionParams = {
        "launchType" : "message"
    };

    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);
    }

    citrix.receiver.createSession(citrixReceiverId,connectionParams,sessionCreated);
}catch(ex){
    console.log(ex);
}
<!--NeedCopy-->

Example 2: The following code launches an app/desktop in an appview element inside the third party Chrome app.

function createAppview() {
    if (!appView) {
        appView = document.createElement("appview");
        appView.id = "appView";
        // Appends the element to the document body.
        document.body.appendChild(appView);

        // Sample code for setting appview properties. Modify as needed.
        appView.style.width = "800px";
        appView.style.height = "800px";
        appView.style.left = "0px";
        appView.style.top = "100px";
        appView.style.position = "absolute";
    } else {
        appView.style.display = "block";
    }
}

//Use appropriate citrix receiver id. This sample uses store version.
//EAR = lbfgjakkeeccemhonnolnmglmfmccaag , store version = haiffjcadagjlijoggckpgfnoeiflnem
var citrixReceiverId = "haiffjcadagjlijoggckpgfnoeiflnem";

try{
    createAppview();
    var connectionParams = {
        "launchType" : "embed",
        "container": appView
    };

    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);
    }

    citrix.receiver.createSession(citrixReceiverId,connectionParams,sessionCreated);
}catch(ex){
    console.log(ex);
}
<!--NeedCopy-->

Enumerate sessions

  • This API method returns the list of sessions that are currently active.
    // Citrix chrome SDK API call to enumerate the sessions
    citrix.receiver.enumerateSessions(workSpaceId, responseCallback);
    <!--NeedCopy-->
    
Arguments
Name Type Description
workSpaceId String Indicates the Citrix Workspace App ID required for SDK communication. If the workSpaceId is not specified, then the Citrix Workspace App store ID is used as the default.
enumerateSessionsResponseCallback Function Callback function that handles the enumerate sessions response.

enumerateSessionsResponseCallback(response)

  • Callback function that handles the enumerate sessions response

Parameters

Name Type Description
response Object Enumerate sessions response object, If there is a failure, the details of the error are set in the response object refer here for error response

Enumerate Sessions Response Properties

Name Type Description
response.success Boolean Status of the method call. Holds the value true if successful
response.data Array[Object] Holds the list of active session details (see below) for the properties associated in the data array

Enumerate Sessions Response Data Array

Each object within the response.data array contains the following properties:

Property Type Description
sessionId String Represents the ID of the session
launchType String Represent the type of launch examples: chromeSDK , downloadICA, store, fta, serviceContinuity
initialProgram String Holds the information of the application/desktop that was launched.
title String Represents the title of the resource launched.
Example
//Use appropriate Citrix Workspace App Id. This sample uses store version.
// EAR = lbfgjakkeeccemhonnolnmglmfmccaag , store version = haiffjcadagjlijoggckpgfnoeiflnem
const citrixWorkspaceId = "haiffjcadagjlijoggckpgfnoeiflnem";

// writing the sample function enumerateSessions
function enumerateSessions(workspaceId, enumerateSessionsResponseCallback) {
    try {
        // Citrix chrome HDX API call to enumerate the sessions
       citrix.receiver.enumerateSessions(workspaceId, enumerateSessionsResponseCallback);
    }
    catch (ex) {
        // handle exception
    }
}

// calling the function enumerateSessions
enumerateSessions(citrixWorkspaceId, function(response){
    // business logic to handle the response
});
<!--NeedCopy-->

Sample response

{
  "success": true,
  "data" : [
    {
      "sessionId":"1717756617015",
      "launchType":"store",
      "initialProgram":"#Azure Managed Desktop IC $S81-137",
      "title":"Azure - APAC Managed Desktop"
    },
    {
      "sessionId":"1717756789946",
      "launchType":"store",
      "initialProgram":"#Azure Managed Desktop IC $S81-187",
      "title":"Azure - APAC Managed Desktop"
    }
  ]
}
<!--NeedCopy-->

Disconnect Sessions

  • This API disconnects the sessions based on the session ids provided.
// Citrix chrome HDX API call to disconnect the sessions
citrix.receiver.disconnectSessions(requestFilter, (response) => {
      // business logic to handle the response
});
<!--NeedCopy-->

Arguments

Name Type Description
requestFilter Object Request filter object containing information to perform the disconnect operation. Refer to the section below (requestFilter) for details on supported properties
disconnectSessionsResponseCallback Function Callback function that handles the disconnect sessions response.

requestFilter

Name Type Attributes Description
receiverId String Optional Indicates the Citrix Workspace App ID required for SDK communication. If the workSpaceId is not specified, then the Citrix Workspace App store ID is used as the default.
filter Json Mandatory Contains the information required to filter active sessions and execute a disconnect operation. Refer to the section below (filter properties) for details on supported properties

filter properties

Property Type Attributes Description
sessionIds Array[String] Mandatory Contains the list of session IDs for disconnection.

Sample requestFilter object

/**
 * Inorder to disconnect the session based on the session ids provided, the requestFilter object should be constructed as follows:
 */
const requestFilter = {
        "receiverId": "haiffjcadagjlijoggckpgfnoeiflnem",
        "filter": {
            "sessionIds": ["1719768640524", "1717756789946"]
        }
    };
<!--NeedCopy-->

disconnectSessionsResponseCallback(response)

  • Callback function that handles the Disconnect Sessions response

Parameters

Property Type Description
response Object Holds the disconnect sessions response, If there is a failure, the details of the error are set in the response object refer here for error response

Properties

Property Type Description
response.success Boolean Status of the method call. Holds the value true if successful
response.data array[Object] Provides the list of session disconnect states

Disconnect Sessions Response Data Array

Each object within the response.data array contains the following properties:

Property Type Description
sessionId String Represents the ID of the session
success Boolean Indicates whether the session was successfully disconnected (true) or if the disconnection failed (false).
error String Provides a description of the error if the session failed to disconnect.

Example

// step 1: get the list of active sessions using enumerateSessions API
// step 2: construct the requestFilter object with the session ids to disconnect
// step 3: call the disconnectSessions function with the requestFilter object

//Use appropriate Citrix Workspace App Id. This sample uses store version.
// EAR = lbfgjakkeeccemhonnolnmglmfmccaag , store version = haiffjcadagjlijoggckpgfnoeiflnem

function disconnectSessions(citrixWorkspaceId, disconnectSessionsResponseCallBack) {
    try {
        // Citrix chrome HDX SDK API call to enumerate the sessions
        citrix.receiver.enumerateSessions(citrixWorkspaceId, function(response) {
            // business logic to handle the response
            // construct the requestFilter object with the session ids to perform disconnectSessions operation
            const sessionIds = response.data.map(session => session.sessionId);
            const requestFilter = {
                "receiverId": citrixWorkspaceId,
                "filter": {
                    "sessionIds": sessionIds
                }
            };
            
            // Citrix chrome HDX SDK API call to disconnect the sessions
            citrix.receiver.disconnectSessions(requestFilter, (disconnectSessionsResponse) => {
                // business logic to handle the response
                disconnectSessionsResponseCallBack(disconnectSessionsResponse);
            });
        });
    } catch (ex) {
        console.log(ex);
    }
}
<!--NeedCopy-->

Disconnect Sessions Sample response

{
  "success": true,
  "data": [
    {
      "sessionId": "1717756617015",
      "success": true
    },
    {
      "sessionId": "1717756789946",
      "success": true
    },
    {
      "sessionId": "1817756789946",
      "success": false,
      "error": "Session not found"
    }
  ]
}
<!--NeedCopy-->

Disconnect All Sessions

  • This API method disconnects all the active sessions held by Citrix Workspace App.
// Citrix chrome HDX API call to disconnect the sessions
citrix.receiver.disconnectAllSessions(workSpaceId, (response) => {
        // business logic to handle the response
});
<!--NeedCopy-->
Arguments
Property Type Description
workSpaceId String Indicates the Citrix Workspace App ID required for SDK communication. If the workSpaceId is not specified, then the Citrix Workspace App store ID is used as the default.
disconnectAllSessionsResponseCallBack Function Callback function that handles the disconnect all sessions response.

disconnectAllSessionsResponseCallBack(response)

  • Callback function that handles the Disconnect All Sessions response

Parameters

Property Type Description
response Object Holds the disconnect sessions response, If there is a failure, the details of the error are set in the response object refer here for error response

Properties

Property Type Description
response.success Boolean Status of the method call. Holds the value true if successful
response.data array[Object] Provides the list of session disconnect states

Disconnect All Sessions Response Data Array

Each object within the response.data array contains the following properties:

Property Type Description
sessionId String Represents the ID of the session
success Boolean Indicates whether the session was successfully disconnected (true) or if the disconnection failed (false).
error String Provides a description of the error if the session failed to disconnect.

Example

//Use appropriate Citrix Workspace App id. This sample uses store version.
// EAR = lbfgjakkeeccemhonnolnmglmfmccaag , store version = haiffjcadagjlijoggckpgfnoeiflnem

const citrixWorkspaceId = "haiffjcadagjlijoggckpgfnoeiflnem";

// call disconnectAllSessions Api to disconnect all the sessions
citrix.receiver.disconnectAllSessions(citrixWorkspaceId, (response) => {
    // business logic to handle the response
});
<!--NeedCopy-->

Disconnect All Sessions Sample response

{
  "success": true,
  "data": [
    {
      "sessionId": "1717756617015",
      "success": true
    },
    {
      "sessionId": "1717756789946",
      "success": true
    }
  ]
}
<!--NeedCopy-->

Logout user from all stores

  • This API method logs out the user from the Citrix Workspace App.
// Citrix chrome HDX API call to logout the user from all the stores
citrix.receiver.logOutUserFromAllStores(workspaceId, (response) => {
        // business logic to handle the response
});
<!--NeedCopy-->
Arguments
Name Type Description
workspaceId String Indicates the Citrix Workspace App ID required for SDK communication. If the workSpaceId is not specified, then the Citrix Workspace App store ID is used as the default.
logOutUserFromAllStoresResponseCallback Function Callback function that handles the logOut from all stores response.

logOutUserFromAllStoresResponseCallback(response)

  • Callback function that handles the logOut from all stores response

Parameters

Property Type Description
response Object Holds the disconnect sessions response, If there is a failure, the details of the error are set in the response object refer here for error response

Properties

Property Type Description
response.success Boolean Status of the method call. Holds the value true if successful
response.message String Holds the message of the operation
response.error String Provides a description of the error, if failed to log out the user from all store

Example

//Use appropriate Citrix Workspace App id. This sample uses store version.
// EAR = lbfgjakkeeccemhonnolnmglmfmccaag , store version = haiffjcadagjlijoggckpgfnoeiflnem

const citrixWorkspaceId = "haiffjcadagjlijoggckpgfnoeiflnem";

// call logOutUserFromAllStores Api to logout the user from all the stores
citrix.receiver.logOutUserFromAllStores(citrixWorkspaceId, (response) => {
     // business logic to handle the response
});
<!--NeedCopy-->

Logout user from all stores Sample response

{
  "success": true,
  "message": "User logged out from all the stores successfully."
}
<!--NeedCopy-->
Namespace: receiver