public interface RemoteDesktopClient extends Plugin
Remote desktop client is a high level interface describing common capabilities of remote desktop technologies. The point is to provide a common API to most existing remote desktop protocols such as RFB (aka VNC), RDP and others. The term "remote" is not exact here because the client can in fact be implemented to connect to the local desktop, such as for example the Java client or VNC client and server running on the same Windows instance.
Particular remote desktop capabilities are described through
interfaces in the com.tplan.robot.remoteclient.capabilities
package.
They declare what the client can do with regard to its protocol.
For example, if the client is able to transfer key strokes typed on the local
keyboard to the remote desktop, it should declare this capability through
implementation of the KeyTransferCapable
interface.
Clients are typically implemented as plugins. They are instantiated
indirectly through the RemoteDesktopClientFactory
class by name
of the protocol they implement. For example, an RFB client instance can be
obtained through RemoteDesktopClientFactory.getInstance().getClient("rfb")
.
The factory can also parse a connect URI and create a suitable client, for
example RemoteDesktopClientFactory.getInstance().getClientForURI("rfb://localhost:5901")
.
While these methods may be used in a custom program, a typical T-Plan Robot Enterprise user
creating just test scripts is more likely to call the Connect command
or its corresponding DefaultJavaTestScript.connect(java.lang.String, java.lang.String, java.lang.String, boolean)
Java method.
An instantiated client should be first populated with login parameters
such as connect URI (containing protocol, host name and optional port number),
user name and password. This should be done through the setLoginParams(java.util.Map)
method.
The parameter set depends on the protocol (RFB may need just host name and port)
and configuration of particular server (for example, an RFB server may be
configured to require password). Client parameter sets can be easily customized
through the getLoginParamsSpecification()
method. Particular parameter
values may be then specified through the Login Dialog, through the --clientparam
CLI option or through the connect()
method of Java Test Script API
.
Once the login parameters are passed to the client, an attempt to connect
to the desktop through the connect()
method may be invoked. The client
is expected to fire expected server events
to all
registered RemoteDesktopServerListener
listeners. It should also fire
client events
to all registered RemoteDesktopClientListener
instances. Correct implementation of the event system is essential for the
framework to work correctly.
T-Plan Robot Enterprise, (C) 2009-2022 T-Plan Limited. All rights reserved.
Modifier and Type | Field and Description |
---|---|
static String |
LOGIN_PARAM_PASSWORD
Constant for password.
|
static String |
LOGIN_PARAM_URI
Constant for server URI.
|
static String |
LOGIN_PARAM_USER
Constant for user name.
|
Modifier and Type | Method and Description |
---|---|
void |
addClientListener(RemoteDesktopClientListener listener)
Add a client listener.
|
void |
addServerListener(RemoteDesktopServerListener listener)
Add an RFB server listener to the client.
|
Thread |
close()
Close the connection to the RFB server.If there's no connection, the
method should do nothing.
|
Thread |
connect()
Connect the client to the specified host.
|
void |
destroy()
Destroy the client.
|
String |
getConnectString()
Get the connect string (URL).
|
int |
getDefaultPort()
Get the default server port.
|
int |
getDesktopHeight()
Get the remote desktop height.
|
String |
getDesktopName()
Get the remote desktop name.
|
int |
getDesktopWidth()
Get the remote desktop width.
|
String |
getHost()
Get the server host name.
|
Image |
getImage()
Get the remote desktop image.
|
MouseEvent |
getLastMouseEvent()
This is a convenience method allowing to track the mouse pointer coordinates.
|
List<Preference> |
getLoginParamsSpecification()
Get the list of login parameters (parameters).
|
String |
getPassword()
Get the password.
|
int |
getPort()
Get the port of the target RFB server.
|
String |
getProtocol()
Get the protocol and eventually version supported by the client.
|
String |
getUser()
Get the user.
|
boolean |
hasSufficientConnectInfo()
Indicate whether the client has sufficient connect information or not.
|
boolean |
isConnected()
Should indicate whether the client is connected to an RFB server, i.e.
|
boolean |
isConnectedTo(String connectString)
Test whether this client is connected to a desktop identified by a
particular URL (connect string).
|
boolean |
isConnecting()
Should indicate whether the client is currently connecting to an RFB
server but the communication hasn't passed the authentication and init
phases, i.e.it is in the process of initial handshake, authentication or
exchange of session parameters.
|
boolean |
isConsoleMode()
Indicates if the client runs in the console or GUI mode.
|
boolean |
isLocalDisplay()
Find out whether the client is connected to the local display.
|
boolean |
isLocalDisplay(Rectangle r)
Test out if the argument rectangle intersects the automated screen.
|
void |
removeClientListener(RemoteDesktopClientListener listener)
Remove an object from the list of client listeners.
|
void |
removeServerListener(RemoteDesktopServerListener listener)
Remove an object from the list of server listeners.
|
void |
sendClientCutText(String text)
Implementation of the ClientCutText client-to-server RFB v3.3 message.The
method is supposed to send the update of the local clipboard to the
server.
|
void |
setConsoleMode(boolean consoleMode)
Set the console mode flag.
|
void |
setLoginParams(Map<String,Object> params)
Set the client login parameter values.
|
checkDependencies, getCode, getDate, getDescription, getDisplayName, getImplementedInterface, getLowestSupportedVersion, getMessageAfterInstall, getMessageBeforeInstall, getSupportContact, getUniqueId, getVendorHomePage, getVendorName, getVersion, requiresRestart
static final String LOGIN_PARAM_URI
static final String LOGIN_PARAM_PASSWORD
static final String LOGIN_PARAM_USER
boolean isLocalDisplay()
Find out whether the client is connected to the local display. By "local display" we mean the very same desktop displayed on the local display device (such as users's computer screen). An example of a local display is VNC server running on Windows or Java client connected directly to the system desktop buffer. On contrary, VNC servers running on ports 5901 and higher on a local Linux/Unix machine (localhost:1, localhost:2,...) must not be considered local by this method.
Value returned by this method affects behavior of the T-Plan Robot Enterprise GUI. If the display is local, the viewer doesn't display the desktop image because it would lead to recursive image (infinite mirroring effect). When a test script is executed on the local display, the GUI minimizes in order to hide from eventual screenshots.
boolean isLocalDisplay(Rectangle r)
r
- a rectangle.String getProtocol()
String getHost()
setHost()
, the method returns null.int getPort()
int getDefaultPort()
String getPassword()
setPassword()
, the method returns null.String getUser()
setLoginParams(java.util.Map)
, the method returns null.int getDesktopWidth()
int getDesktopHeight()
String getDesktopName()
boolean isConsoleMode()
In GUI mode the client should rather fire the messages to all registered RfbServerListener instances. The GUI components should then report the messages in an appropriate way.
void setConsoleMode(boolean consoleMode)
consoleMode
- false indicates that the application runs in GUI mode,
true indicates CLI one.MouseEvent getLastMouseEvent()
sendMouseEvent()
and return it through this method.Image getImage()
boolean isConnected()
boolean isConnecting()
Thread connect() throws Exception, com.tplan.robot.remoteclient.rfb.PasswordRequiredException
Exception
- on any other error.com.tplan.robot.remoteclient.rfb.PasswordRequiredException
- if the
connection requires a password and it is not provided.boolean hasSufficientConnectInfo()
Thread close() throws IOException
Close the connection to the RFB server.If there's no connection, the method should do nothing.
IOException
- on an I/O error.void sendClientCutText(String text) throws IOException
text
- content of the local clipboard.IOException
- on an I/O error.void addServerListener(RemoteDesktopServerListener listener)
listener
- an object implementing the RfbServerListener
interface.void removeServerListener(RemoteDesktopServerListener listener)
listener
- an object implementing the RfbServerListener
interface.void addClientListener(RemoteDesktopClientListener listener)
listener
- an object implementing the RemoteDesktopClientListener
interface.void removeClientListener(RemoteDesktopClientListener listener)
listener
- an object implementing the RemoteDesktopClientListener
interface.List<Preference> getLoginParamsSpecification()
void setLoginParams(Map<String,Object> params)
Set the client login parameter values. This is the entry point to specify
connection URI (parameter name LOGIN_PARAM_URI
), user name (LOGIN_PARAM_USER
)
and password (LOGIN_PARAM_PASSWORD
). The client is expected to parse
the URI for the host name and port number to be returned by the getHost()
and
getPort()
methods. The point is to let the client to provide default
values when the URI doesn't contain them.
Save for these standard parameters listed above
the table can be populated with any other protocol specific parameters
understood by the client. Any such parameter should be declared through
the getLoginParamsSpecification()
method to make the
Login Dialog
to display an appropriate GUI component
and allow user to enter a parameter value.
Custom parameters can be also passed through the --clientparam
CLI option. Any such instance will be parsed and passed to the client
through this method.
params
- map of the [parameter name, parameter value] pairs.void destroy()
String getConnectString()
boolean isConnectedTo(String connectString)
connectString
- an URL (connect string).