This interface consists of methods, properties and events supported by the Remote Connection Manager Object.
This interface is exposed by the global object remote
.
interface IRemoteHost {
// Properties
readonly ${connections}: string[];
// Methods
${connectServer}(serverName: string): boolean;
${disconnectServer}(serverName: string): boolean;
// Events
${connected}(handler: (serverName: string) => void): number;
${connected}(eventId: number): void;
${disconnected}(handler: (serverName: string) => void): number;
${disconnected}(eventId: number): void;
}
// This interface is not available in managed environment
// This interface is not available in native environment
readonly connections: string[];
// This property is not available in managed environment
// This property is not available in native environment
Returns the array of strings representing connected computer names.
Connect to a remote server and print the number of connections:
if (remote.connectServer("remote_server_name"))
alert("Number of connections: " + remote.connections.length);
connectServer(serverName: string): boolean;
// This method is not available in managed environment
// This method is not available in native environment
serverName
Returns true
if connection was successfully made, and false
otherwise.
Establishes a remote connection. Pass a resolvable computer name (DNS name, NETBIOS name, IP address and so on) of a remote computer.
Connect to a remote server and print the number of connections:
if (remote.connectServer("remote_server_name"))
alert("Number of connections: " + remote.connections.length);
disconnectServer(serverName: string): boolean;
// This method is not available in managed environment
// This method is not available in native environment
serverName
Returns true
if connection was successfully disconnected, and false
otherwise.
Closes a remote connection. Pass a resolvable computer name (DNS name, NETBIOS name, IP address and so on) of a remote computer.
Disconnect a given connection:
remote.disconnectServer("remote_server_name");
connected(handler: (serverName: string) => void): number;
connected(eventId: number): void;
serverName
This event is fired when new remote connection is established.
First overload is used to bind new handler to the event. It returns a numeric eventId
which then may be passed to second overload to unbind a handler.
Subscribing to connected and disconnected events:
remote.connected(serverName=>alert("Connected: " + serverName + ". Total connections: " + remote.connections.length));
remote.disconnected(serverName=>alert("Disconnected: " + serverName + ". Total connections: " + remote.connections.length));
disconnected(handler: (serverName: string) => void): number;
disconnected(eventId: number): void;
serverName
This event is fired when existing remote connection is closed.
First overload is used to bind new handler to the event. It returns a numeric eventId
which then may be passed to second overload to unbind a handler.
Subscribing to connected and disconnected events:
remote.connected(serverName=>alert("Connected: " + serverName + ". Total connections: " + remote.connections.length));
remote.disconnected(serverName=>alert("Disconnected: " + serverName + ". Total connections: " + remote.connections.length));