public class RemoteConnection extends Object
Modifier and Type | Field and Description |
---|---|
static int |
AUTO_START_EMULATOR |
static int |
AUTO_START_IS_VM_APPLICATION |
static int |
AUTO_START_SERVICE |
static int |
AUTO_START_UNREGISTER_FROM_ALL |
static int |
MANUAL_MOBILE_START_ON_EMULATOR |
static int |
MOBILE_GET_COMMAND_FROM_REGISTRY |
static int |
MOBILE_IS_VM_APPLICATION |
static int |
STATUS_IS_DESKTOP
This is returned by getStatus().
|
static int |
STATUS_IS_EMULATOR
This is returned by getStatus().
|
static int |
STATUS_IS_MOBILE
This is returned by getStatus().
|
Modifier | Constructor and Description |
---|---|
protected |
RemoteConnection() |
Modifier and Type | Method and Description |
---|---|
Socket |
connectToHost(String host,
int port,
TimeOut howLong)
Return a Socket connected to the specified host and port.
|
Socket |
connectToService(String service,
TimeOut howLong)
This is used by an application to connect to a service on the remote machine.
|
static ServerSocket |
createService(String serviceName)
This creates a ServerSocket on a new port and then posts the service to the RemoteConnecion.
|
static ServerSocket |
createServiceServerSocket()
This is the most reliable way to create a ServerSocket for providing
a service over the RemoteConnection.
|
static ServerSocket |
createServiceServerSocket(int port,
int backlog)
This is the most reliable way to create a ServerSocket for providing
a service over the RemoteConnection.
|
void |
execRemote(String[] commandLines,
int execOptions)
Run command lines on the remote.
|
void |
execRemote(String commandLine,
int execOptions)
Run a command line on the remote.
|
void |
exitSystemOnClosedConnection() |
static RemoteConnection |
getConnection()
Use this to get an instance of a RemoteConnection.
|
Handle |
getConnectionHandle()
Return a Handle that can be used to monitor the connection to the Remote Server.
|
static RemoteConnection |
getNewConnection()
Use this to get a new instance of a RemoteConnection.
|
String |
getRegistryValue(String keyName)
Return a registry key value from the remote entity.
|
String |
getService(String name) |
int |
getStatus()
This is used to check the RemoteConnection status.
|
boolean |
isEmulated() |
boolean |
isMobile() |
static void |
main(String[] args) |
Socket |
makeSyncConnection(String serviceName,
String[] commandLines,
TimeOut howLong,
int makeOptions)
This is a convenience method for doing standard application synchronization that can be
be run on both the desktop and mobile device.
|
Socket |
makeSyncConnection(String serviceName,
String commandLine,
TimeOut howLong,
int makeOptions)
This is a convenience method for doing standard application synchronization that can be
be run on both the desktop and mobile device.
|
void |
postService(String service,
ServerSocket serverSocket)
This is used by an application to notify the connection that it has created
and is listening to a TCP/IP server port on the specified hostName and port number.
|
void |
postService(String service,
String hostName,
int port)
This is used by an application to notify the connection that it has created
and is listening to a TCP/IP server port on the specified hostName and port number.
|
static void |
registerAutoStart(String entryName,
String commandLine,
int typeAndOptions)
Use this to register an AutoStart entry.
|
static void |
registerAutoStartVMApp(String entryName,
String vmCommandLine)
This registers a normal autostart entry specifying the entry name and a command line that is
taken to be a VM application.
|
static void |
unregisterAutoStart(String entryName,
int type)
Use this to unregister an AutoStart entry.
|
static void |
unregisterFromAllAutoStarts(String entryName) |
public static final int STATUS_IS_DESKTOP
public static final int STATUS_IS_MOBILE
public static final int STATUS_IS_EMULATOR
public static final int MOBILE_IS_VM_APPLICATION
public static final int MANUAL_MOBILE_START_ON_EMULATOR
public static final int MOBILE_GET_COMMAND_FROM_REGISTRY
public static final int AUTO_START_IS_VM_APPLICATION
public static final int AUTO_START_EMULATOR
public static final int AUTO_START_SERVICE
public static final int AUTO_START_UNREGISTER_FROM_ALL
protected RemoteConnection() throws IOException
IOException
public boolean isEmulated()
public boolean isMobile()
public int getStatus()
public static RemoteConnection getConnection() throws IOException
IOException
- if there is an error getting the connection.public Handle getConnectionHandle()
public void exitSystemOnClosedConnection()
public static RemoteConnection getNewConnection() throws IOException
IOException
- if there is an error getting the connection.public Socket connectToHost(String host, int port, TimeOut howLong) throws IOException, InterruptedException
host
- port
- howLong
- IOException
InterruptedException
public String getService(String name) throws IOException
IOException
public Socket connectToService(String service, TimeOut howLong) throws IOException, InterruptedException
IOException
InterruptedException
public void execRemote(String[] commandLines, int execOptions) throws IOException
commandLines
- The line to run or remote Registry value that stores the command to be run.execOptions
- This can be any of MOBILE_GET_COMMAND_FROM_REGISTRY, MOBILE_IS_VM_APPLICATION, OR'ed together.IOException
- If the command could not be executed.public void execRemote(String commandLine, int execOptions) throws IOException
commandLine
- The line to run or remote Registry value that stores the command to be run.execOptions
- This can be any of MOBILE_GET_COMMAND_FROM_REGISTRY, MOBILE_IS_VM_APPLICATION, OR'ed together.IOException
- If the command could not be executed.public String getRegistryValue(String keyName)
keyName
- the name of the key.public static void unregisterFromAllAutoStarts(String entryName)
public static void unregisterAutoStart(String entryName, int type)
entryName
- the name of the entry.options
- this should be only one of AUTO_START_EMULATOR
(to unregister from the auto-start emulator services), AUTO_START_SERVICE
(to unregister from the service list) or AUTO_START_UNREGISTER_FROM_ALL to
remove it from all.
If it is zero then it is unregistered from the normal auto-start entries only.public static void registerAutoStart(String entryName, String commandLine, int typeAndOptions) throws IOException
entryName
- A unique name for the entry. You can use spaces or special characters,
but not the backslash (\) character.commandLine
- The command line to run. This should be a full command line, or it can
be a command line to the EveVM if the AUTO_START_IS_VM_APPLICATION option is chosen.typeAndOptions
- This can be a combination of AUTO_START_IS_VM_APPLICATION with
AUTO_START_EMULATOR or AUTO_START_SERVICE. If neither AUTO_START_EMULATOR nor AUTO_START_SERVICE
is selected, then it is assumed that the entry is in the normal (default) auto start section.IOException
- If the information could not be registerd.public static void registerAutoStartVMApp(String entryName, String vmCommandLine) throws IOException
entryName
- A unique name for the entry. You can use spaces or special characters,
but not the backslash (\) character.commandLine
- The command line to run with the VM.IOException
- If the information could not be registerd.public void postService(String service, String hostName, int port) throws IOException
service
- The service name to post. Note that this IS case sensitive.hostName
- The name of the host used for the connection.port
- The port number of the connection.IOException
public void postService(String service, ServerSocket serverSocket) throws IOException
service
- The service name to post. Note that this IS case sensitive.serverSocket
- The socket being listened to.IOException
public static ServerSocket createServiceServerSocket() throws IOException
IOException
- if there was an error creating the Socket.public static ServerSocket createServiceServerSocket(int port, int backlog) throws IOException
port
- a specific port to listen to - which can be 0 to select
any available port.backlog
- the backlog of incoming connections to allow. 0 will select
the default backlog.IOException
- if there was an error creating the Socket.public static ServerSocket createService(String serviceName) throws IOException
serviceName
- The name of the service to be posted.IOException
- If the ServerSocket could not be created or if the service
could not be posted.public Socket makeSyncConnection(String serviceName, String commandLine, TimeOut howLong, int makeOptions) throws TimedOutException, IOException, InterruptedException
If it is running on the desktop it will do the following:
1. Create a server socket on an arbitrary port. 2. Post the service name and the socket port. 3. Execute the remote command line, unless the MANUAL_MOBILE_START_ON_EMULATOR option is selected in which case a MessageBox is shown if the connection is running on the Evesync Emulator and you must start the mobile app yourself. If the MOBILE_GET_COMMAND_FROM_REGISTRY option is used, then the command line supplied should be the name of a value in the registry key - this value will be retrieved and then run. If MOBILE_IS_VM_APPLICATION option is used then the value retrieved from the registry should be the location of a .eve file. 4. Wait for a connection.
If it is running on the mobile this method will:
1. Attempt to connect to the serviceName on the remote host.
serviceName
- The unique service name to be used.commandLine
- A command line to pass to the Ewe VM on the remote device.howLong
- The length of time to wait for a connection.makeOptions
- This can be any of MANUAL_MOBILE_START_ON_EMULATOR, MOBILE_IS_VM_APPLICATION OR'ed together.TimedOutException
- If no connection was made during the Timeout period.IOException
- If there was an error making the connection.InterruptedException
- If the Thread was interrupted while waiting for the connection.public Socket makeSyncConnection(String serviceName, String[] commandLines, TimeOut howLong, int makeOptions) throws TimedOutException, IOException, InterruptedException
If it is running on the desktop it will do the following:
1. Create a server socket on an arbitrary port. 2. Post the service name and the socket port. 3. Execute the remote command lines, unless the MANUAL_MOBILE_START_ON_EMULATOR option is selected in which case a MessageBox is shown if the connection is running on the Evesync Emulator and you must start the mobile app yourself. If the MOBILE_GET_COMMAND_FROM_REGISTRY option is used, then the command lines supplied should be the name of a value in the registry key - this value will be retrieved and then run. If MOBILE_IS_VM_APPLICATION option is used then the value retrieved from the registry should be the location of a .eve file. 4. Wait for a connection.
If it is running on the mobile this method will:
1. Attempt to connect to the serviceName on the remote host.
serviceName
- The unique service name to be used.commandLines
- An array of command lines to pass to the Eve VM on the remote device.howLong
- The length of time to wait for a connection.makeOptions
- This can be any of MANUAL_MOBILE_START_ON_EMULATOR, MOBILE_IS_VM_APPLICATION, MOBILE_GET_COMMAND_FROM_REGISTRY OR'ed together.TimedOutException
- If no connection was made during the Timeout period.IOException
- If there was an error making the connection.InterruptedException