Events

Events

The events parameter allows you to handle each one of the available Thinfinity® Remote Desktop Server events from the SDK.

events: {
 onServerConnecting : function (reconnecting) { },
 onServerConnect : function () { },
 onQueryDisconnect : function () { },
 onServerConnectionError : function (errMessage) { },
 onServerDisconnect : function () { },
 onExecResult : function (cmd) { },
 onSessionStart : function () { },
 onSessionEnd : function (message) { },
 }

Observe in the code above that all the event functions are empty. In the following table you can find a description, parameters and a use example for each one of the available events:

Event

Parameters

When it is triggered

Example

events.onServerConnecting

reconnecting

This event is fired during the server connection establishment.

The 'reconnecting' argument informs whether this is a reconnection or a first-time connection.

onServerConnecting :

function (reconnecting) {

$.blockUI("Establishing connection");

}

events.onServerConnect

obj

The "onServerConnect" event is fired every time a "connect" command is exchanged between the browser and Thinfinity® Remote Desktop Server. It is a way of making sure the server received a sent "connect" command.

If you have shown a message on the onServerConnecting, this would be a good moment to hide that message ($.unblockUI();).

The 'obj' parameter ships the generated connection object.

onServerConnect :

function (obj) {

$.unblockUI();

}

events.onQueryDisconnect

-

Anytime the Web client is about to be disconnected, the "onQueryDisconnect" will

be triggered. This is useful to ask the user for confirmation before proceeding to disconnect.

onQueryDisconnect: function () {

if (confirm("A remote session is active. Are you sure you want to disconnect?"))

{

mythinrdp.disconnect();

}

}

events.onServerConnectionError

errMessage

If an error prevents the client connection to be established, this event will be fired. The errMessage argument brings the error message.

onServerConnectionError: function (errMessage){

alert("connect error: " + errMessage);

}

events.onServerDisconnect

-

Anytime the Web client gets disconnected from Thinfinity® Remote Desktop Server, the "onServerDisconnect" event will be fired. It could be triggered because the connection was lost incidentally or also because the user disconnected from the server on purpose.

onServerDisconnect: function () {

alert("disconnect");

$.unblockUI();

mythinrdp.updateTools();

$("#" + mythinrdp.rcParams.divId).hide();

}

events.onExecResult

cmd

This event fires only when the SDK is integrated with a remoteApp application.

Through this event it is possible to get to know if the remoteApp was started or if there was an error during the application start up.

If the application was started without errors, the cmd.rc is going to be 0, otherwise cmd.rc will carry the application error code. As you can see on the example below you can also get the executable name accessing the cmd.exename value.

onExecResult: function (cmd) {

alert("exename: " + cmd.exename + " rc: " + cmd.rc);

}

event.onExecRemoteApp

This event is fired when the remote server starts the execution of a RemoteApp.

onExecRemoteApp: function (cmd) {

alert("The application is starting");

}

event.onInteractionRequired

This event is fired during the connection process to a RemoteApp either when the systems requires a user interaction to proceed before being able to open the application —such as a UAC prompt—; or when the application is ready.

In some cases, the application might be starting and the user might not have access to the blocked screen, so it might need to be unblocked programatically.

onInteractionRequired: function () {

$.UnBlockUI();

}

events.onSessionStart

-

This event will be fired when the client session has been started in Thinfinity® Remote Desktop Server.

onSessionStart: function () {

$("#" + mythinrdp.rcParams.divId).show();

mythinrdp.updateTools();

}

events.onSessionEnd

message

As soon as the client Session is closed, the "onSessionEnd" event will be fired.

onSessionEnd: function (message) {

alert(message);

},

Note 1 : This event usage reference can also be found in the sdk.html file, located in the application directory, under the "webrdp" directory.

Note 2 : In versions previous to 2.2.0.20 the SDK events had a different syntax. That old sintax is still compatible with newer versions. However, it is highly recommended to translate the old code to the method described above.

This is how the previous event names are related to new ones:

Old Event Name

Current Event Name

establishingConnection

events.onServerConnecting

serverConnect

events.onServerConnect

execResult

events.onServerConnect

sessionStart

events.onSessionStart

serverConnectionError

events.onServerConnectionError

disconnectConfirmRequest

events.onQueryDisconnect

serverDisconnect

events.onServerDisconnect

sessionEnd

events.onSessionEnd

Last updated