Device Monitoring Studio - Monitor, log and analyze data coming through PC ports and connections
Download Device Monitoring Studio Hide this button

IRemoteHost Interface

This interface consists of methods, properties and events supported by the Remote Connection Manager Object.

This interface is exposed by the global object remote.

Declaration

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

IRemoteHost Properties

connections

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);

IRemoteHost Methods

connectServer

connectServer(serverName: string): boolean;
// This method is not available in managed environment
// This method is not available in native environment
serverName
Server name.

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

disconnectServer(serverName: string): boolean;
// This method is not available in managed environment
// This method is not available in native environment
serverName
Server name.

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");

IRemoteHost Events

connected

connected(handler: (serverName: string) => void): number;
connected(eventId: number): void;

serverName
Name of a remote computer.

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

disconnected(handler: (serverName: string) => void): number;
disconnected(eventId: number): void;

serverName
Name of a remote computer.

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));