Skip to main content

6.2.4 – Usage of RDP class


Name                                                                               Type                           Description
appTimeout Int Close the RemoteApp if no Windows found after this period, default is 800 ms.
displayMsg Boolean If display error or warning message, default is true
reconnectOnResize Boolean If reconnect when resize the browser window, default is true
reconnectTimes Int Automatically reconnecting time,default 0.
sessionTimeout Int Close the session disconnection if no RemoteApp running after this period. Default value is 3000 (3 seconds). You may want to make it longer, so user can use the current session for new RemoteApp.
windowState Int State of RemoteApp main window, 3: always maximized, 0: controlled by user
openLink Boolean Display a web link button when user copy a web link in remote computer, default is true
sessionInfo Object Current session information. Including following properties: sessionId, userName, domain etc.
remoteAppLogin Boolean If display login details when using RemoteApp, default is true
setTitle Boolean If allow client to change browser title, default is true, the browser title will be set as the RDP host name.


Name                                                                                                                                                                                                                                                                                                                                                                                                   Description
close() Close current RDP session
exeAppCmd(cmd) Execute command on current RemoteApp, cmd (Int) values:
0xF020: Minimize the window
0xF030: Maximize the window
0xF060: Close the window
0xF100: Display the windo’s system menu
0xF120: Restore the window
mouseDown(x, y, button) Send mouse down to RDP host. X, Y: mouse position, button: which button, same as event.button.
mouseUp(x, y, button) Send mouse up to RDP host.
mouseMove(x, y) Send mouse move to RDP host.
pauseSession(numericId, pause) Pause a session output, pause: true or false. Pause all joined sessions if numericId is 0
running() Check if connected to a RDP session
setAudioBuffer(seconds) Audio buffer size, default is 2.0 seconds
writeKeyCode(down, keyCode) Send browser keyCode to RDP host. “down”: Boolean
writeText(txt, interval, doneCallback) Send Unicode to RDP host. RDP server could ignore some characters if the client is sending them too fast. Please use the optional interval and call back arguments.
writeRawInput(input) Send raw keyboard, mouse events to RDP host. Please use
onactivity event to get the raw input events.
writeKeyComb(keys, interval, doneCallback) Write any key combinations like “Ctrl+Alt+Del”. if interval > 0, every key stroke (down or up) will be sent with delay.
notify(message, sessionIDArray) Send message to other session. sessionIDArray is optional. If sessionIDArray is not given, this will send message to all other joined and main session. If sessionIDArray is provided, it will send message to sessions with the given ID. For example: [id1, id2, id3]. The id can be the 9 digit number id or the GUID.
saveSession(info) This will leave the session open on the gateway, so you can connect to it later from same or different device. For example: saveSession({save: true, timeout:5, id: xxxx}) will leave the session open for 5 minutes on gateway with id xxxx. You can connect to this cached session with the given id. Please check 3.14 for more information about cached session. You can also use plugin to save session. This feature will be disabled if savedSessionTimeout in gateway.conf is 0.
startPing(interval, noResponTime) Start to ping the gateway when the session is idle. Interval: seconds. noResponTime: seconds, time limit for no response. onnoresponse event will be fired if this value reached, default is 0 will never fire onnoresponse event.
setJoinMode(mode) 0: Every one can control; 1: Only one can control; 2: Only one can control (others can move mouse)
setJoinCloseMode(mode) 0: close all joined sessions after initiated session is closed; 1: leave all joined sessions open even initiated session is closed.
writeClipboard(text, type) dp.writeClipboard('Plain text');
rdp.writeClipboard('<h>Header</h>', 'text/html');
var reader = new FileReader();
reader.onloadend = function (e) {
if ( == FileReader.DONE) {
var imgB64 = hi5.Base64.enc(new Uint8Array(;
rdp.writeClipboard(imgB64, 'image/png');
sendKeyboardSynchronize(scroll, numlock, capital) Turn off/on lock key state on remote computer.


Name                                                                                         Description
onclose(expected) Fired when RDP session is closed. Expected is true if the session is closed by user (log off) or administrators. Please be aware, the Rdp object will be released and cannot be reused after this event.
onerror(error) Fired on an error. Use, error.message to get error details.
onloggedin() Fired when user logged in (It's not supported by xRDP and VirtualBox RDP)
beforeupload(file, path) Fired before uploading a file:

file: File object
path: file absolute path or name if path cannot be obtained.

Return true if it's processed and prevent default behavior happening.
onfileuploaded(fileName) Fired after a file was uploaded
onuploaded() Fired after all files were uploaded
onsessionjoin(appInfo) Fired when a new user joined the session. appInfo has following properties:

numericId: the 9 digit id
__ip: joined user’s hone name or ip address
name: if provided

Return true will override the default behavior.
onsessionexit(sessionInfo) Fired when a joined user existed the session.
Return true will override the default behavior.
ongivecontrol() Fired when current user can control the session.
Return true will override the default behavior.
ontakebackcontrol() Fired when current user cannot control the session anymore
onrequirecontrol() Fired when another require current user to control the session.
onremoteappstart(e) Fired after a RemoteApp was started, you can get the RemoteApp id from which is like:

onactivity(input) Fired after a client activity was sent to the server (Mouse, keyboard events). Input (string) is the mouse and keyboard event. You can use writeRawInput to send them to the RDP host.
onurlredirection(URL) Fired when an URL was copied on remote computer
ontitlechange(title) Fired when client before change the browser title. You can return a new title in this event.
onsessionstart(sessionInfo) sessionInfo is same as the sessionInfo property
onservercopy(strValue) Fired when copying from remote to local. strValue is in “mimeType;value” format, for example: “text/plain;textCopied”.
onrequestcredential(info) Fired when wrong credential was given and credSSP is enabled on gateway). Return true will override the default behavior. Info object has following properties:

domain: server’s FQDN domain name
nbDomain: server’s NetBIOS domain name
nbComputer: server’s NetBIOS computer name
onprintingready(printJob) Return true will override the default behavior. printJob has following properties:

link: the PDF file link
printerName: target printer name
printerDriver: target printer driver name
onresolutionchange(width, height) Fired when resolution of RDP session changes.
onnoresponse() Need to be used with startPing(interval, missTimes)
onLockKeyState({"capsLock": capsLock, "numLock": numLock, "scrollLock": scrollLock)