Session
new Session()
Members
container
Contains the type and value of the container where the session is launched.
Properties
(readonly) id
Properties
Name | Type | Description |
---|---|---|
id |
String | ID of the object |
Methods
(inner) addListener(eventType, eventListener)
Registers the eventListener on the eventType.
Parameters
Name | Type | Description |
---|---|---|
eventType |
String | Type of the event for which the listener needs to be attached. Supported event types: - onConnection - onConnectionClosed - onURLRedirection - onError - onResize |
eventListener |
eventListener | Listener to handle the event |
Example
// 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);
//Adding onResize event handler
function onResizeHandler(event){
console.log("Event Received : " + event.type);
console.log(event.data);
}
sessionObject.addListener("onResize",onResizeHandler);
<!--NeedCopy-->
(inner) addToolbarBtns(customToolbarData)
Adds the custom buttons to the in-session toolbar.
Parameters
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
customToolbarData |
Array.<Object> |
Array of objects containing the custom toolbar buttons to be added where each object contains more details of the button to be added. Note: Toolbar should be enabled to use this method. Properties
|
Examples
Example 1: Adding help custom button to primary toolbar and position is set to rear(added before more button)
function helpButtonHandler(eventObj){
console.log("Event Received : " + event.type);
console.log(event.data);
}
var customToolbarData = [{"id" :"help","config":{"position":"rear","imageUrl":"http://<path_of_the_image>/help.png","toolTip":"Help"},"handler":helpButtonHandler}];
sessionObject.addToolbarBtns(customToolbarData);
<!--NeedCopy-->
Example 2: Adding back and forward buttons that allows navigation of the webpage in browser and position is set to front (added after Workspace app button).
function backButtonHandler(eventObj){
console.log("Event Received : " + event.type);
console.log(event.data);
sessionObject.sendSpecialKeys(["ALT_KEY","LEFT_ARROW"]);
}
function forwardButtonHandler(eventObj){
console.log("Event Received : " + event.type);
console.log(event.data);
sessionObject.sendSpecialKeys(["ALT_KEY","RIGHT_ARROW"]);
}
var customToolbarData = [];
customToolbarData.push({"id" :"back","config":{"position":"front","imageUrl":"http://<path_of_the_image>/back.png","toolTip":"Back"},"handler":backButtonHandler});
customToolbarData.push({"id" :"forward","config":{"position":"front","imageUrl":"http://<path_of_the_image>/fwd.png","toolTip": "Forward"},"handler":forwardButtonHandler});
sessionObject.addToolbarBtns(customToolbarData);<br/><br/><br/>
<!--NeedCopy-->
Example 3: Adding help custom button as primary toolbar with position set to rear and contact us button as secondary button.
function helpButtonHandler(eventObj){
console.log("Event Received : " + event.type);
console.log(event.data);
}
function contactUsButtonHandler(eventObj){
console.log("Event Received : " + event.type);
console.log(event.data);
}
var customToolbarData = [];
customToolbarData.push({"id" :"help","config":{"position":"rear","imageUrl":"http://<path_of_the_image>/help.png","toolTip":"Help"},"handler":helpButtonHandler});
customToolbarData.push({"id" :"contactUs","config":{"toolTip":"Help","isPrimary":false},"handler":contactUsButtonHandler});
sessionObject.addToolbarBtns(customToolbarData);
<!--NeedCopy-->
(inner) changeResolution(bounds)
Changes the resolution of the session.
Parameters
Name | Type | Description |
---|---|---|
bounds |
Object | Contains session resolution settings |
Properties
Name | Type | Description |
---|---|---|
bounds.autoresize |
boolean | Should be set to false to give fixed width and height to session. If this value is set to true then the session is resized to match the size of iframe element or the tab. |
bounds.width |
Number | Width of the session specified in pixels. This value will be set only when autoresize is set to false. |
bounds.height |
Number | Height of the session specified in pixels. This value will be set only when autoresize is set to false. |
Examples
Example 1: To change resolution to fixed width and height
var bounds = {
"autoresize":false,
"width": "800",
"height":"600"
}
sessionObject.changeResolution(bounds);
<!--NeedCopy-->
Example 2: To change the session resolution to match the iframe element or tab size
var bounds = {
"autoresize": true
}
sessionObject.changeResolution(bounds);
<!--NeedCopy-->
(inner) disconnect()
Disconnects the session.
(inner) logoff()
Sends logoff to the session.
(inner) removeListener(eventType, eventListener)
Removes the eventListener on the eventType.
Parameters
Name | Type | Description |
---|---|---|
eventType |
String | Type of the event for which the listener needs to be removed. Supported event types: - onConnection - onConnectionClosed - onURLRedirection - onError - onResize |
eventListener |
eventListener | Listener to handle the event |
Example
//Removing the event handler for onConnection event
function connectionHandler(eventObj){
console.log("Event Received : " + event.type);
console.log(event.data);
}
sessionObject.removeListener("onConnection",connectionHandler);
<!--NeedCopy-->
(inner) removeToolbarBtns(toolbarButtonIds)
Removes the custom toolbar buttons added to in-session toolbar.
Parameters
Name | Type | Description |
---|---|---|
toolbarButtonIds |
Array <String> | Array of custom toolbar button ids to be removed. |
Example
Example 1: Removing the help button added using addToolbarBtns example.
sessionObject.removeToolbarBtns(["help"]);
<!--NeedCopy-->
Example 2: Removing multiple buttons say back and forward buttons added using addToolbarBtns example.
sessionObject.removeToolbarBtns(["back","forward"]);
<!--NeedCopy-->
(inner) sendSpecialKeys(keys)
Sends a key combination to the session.
Parameters
Name | Type | Description |
---|---|---|
keys |
Array | Array of strings with each one representing a key. Supported keys Alt, Control, Shift, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, Home, End, PageUp, PageDown, Backspace, Delete, F5, PrintScreen,Insert, Escape, Tab. Till 1.1 version only “ctrl+alt+del” was supported. From 1.2 version, more key combinations can be sent to session. |
Example
Example 1: Sends Ctrl+alt+delete to the session.
var keys = ["Control","Alt","Delete"];
sessionObject.sendSpecialKeys(keys);
<!--NeedCopy-->
Example 2: To preview different apps running inside session, Ctrl+alt+tab can be sent.
var keys = ["Control","Alt","Tab"];
sessionObject.sendSpecialKeys(keys);
<!--NeedCopy-->
(inner) start(launchData)
Starts the session.
Parameters
Name | Type | Description |
---|---|---|
launchData |
Object | Contains the type and value of ICA. |
Properties:
Name | Type | Description |
---|---|---|
launchData.type |
String | Specifies the data type of ICA data. Allowed values are “json” or “ini”. |
launchData.value |
String | ICA data to start the session. It should be a JSON object when type is “json” or a string read from a .ini file when type is “ini”. |
Examples
Example 1: When ICA data is in JSON format
var icaObj = {
"ClientName":"HTML5-Receiver",
"Domain":"<domain_name>",
"ClearPassword":"<password>",
"InitialProgram":"<initial program",
"Title":"<title>",
"Address":"<ip address>",
"Username":"<user name>",
"wsPort":"<port val>"
}
var launchData = {"type" : "json",value : icaObj};
sessionObject.start(launchData);
<!--NeedCopy-->
Example 2: When ICA data is in INI format
var launchData = {"type" :"ini",value :"<ica data in ini format>"};
sessionObject.start(launchData);
<!--NeedCopy-->