There are 3 modules you can import from this package: Client, Protocol, ServerState.
Defines the object types used in communication with the server. Some of these objects are also used as parameters or returned by the client methods. Refer to this file for a complete list of definitions. This should mirror the definitions on the server side here.
Defines constants representing the states a server can be in - including both the state of the server itself and the state of the projects published to the server. See here for a complete list.
The main part that takes care of all the communication. Most methods have a timeout by default, can be changed as an optional last parameter (in milliseconds).
Create a new client by using the constructor:
const client = new RSPClient('host', port);
Initiate the connection:
client.connect();
Disconnect the client:
client.disconnect();
Shut down the RSP server (and disconnect the client):
client.shutdownServer();
Search a path for suitable servers, resolves to an array of ServerBean objects, see Protocol for definition:
client.findServerBeans('path');
Send notification to the RSP to add a directory to its discovery paths. Discovery paths are locations RSP will scan for servers. See events for async handling.
client.addDiscoveryPathAsync('path');
Synchronous version of adding discovery paths, resolves to a DiscoveryPath object, see Protocol for definition:
client.addDiscoveryPathSync('path');
Send notification to the RSP to remove a directory from its discovery paths.
client.removeDiscoveryPathAsync('path' | path: DiscoveryPath);
Synchronous version of removing discovery paths, resolves to a DiscoveryPath object of the path that got removed
client.removeDiscoveryPathAsync('path' | path: DiscoveryPath);
Get all currently used discovery paths, resolves to an array of DiscoveryPath objects:
client.getDiscoveryPaths();
Send a notification to create a server from a path to its root directory or from a ServerBean object with given id. See events for async handling. Resolves to a Status object, see Protocol for definition:
client.createServerAsync('path' | bean: ServerBean, 'id');
Synchronous version of creating a server, resolves to a ServerHandle object:
client.createServerSync('path' | bean: ServerBean, 'id');
Send a notification to delete a server defined by a ServerHandle:
client.deleteServerAsync(serverHandle: ServerHandle);
Synchronous version of deleting a server, resolves to the ServerHandle representing the removed server:
client.deleteServerSync(serverHandle: ServerHandle);
Get handles for all servers, resolves to an array of ServerHandle objects:
client.getServerHandles();
Get all supported server types, resolves to an array of ServerType objects:
client.getServerTypes();
Get required or optional attributes of a particular server type, resolves to an Attributes object:
client.getServerTypeRequiredAttributes(type: ServerType);
client.getServerTypeOptionalAttributes(type: ServerType);
Get possible launch modes for a server type, resolves to an array of ServerLaunchMode objects:
client.getServerLaunchModes(type: ServerType);
Get required or optional launch attributes of a particular server in a particular mode, resolves to an Attributes object:
client.getRequiredLaunchAttributes(request: LaunchAttributesRequest);
client.getOptionalLaunchAttributes(request: LaunchAttributesRequest);
Get the command usable to manually start a server from cli, resolves to a CommandLineDetails object:
client.getServerLaunchCommand(launchParameters: LaunchParameters);
Notify RSP that the client is launching / has launched a server manually, resolves to a Status object:
client.serverStartingByClient(startingAttributes: ServerStartingAttributes);
client.serverStartingByClient(launchParameters: LaunchParameters);
Start a server asynchronously, resolves to a StartServerResponse object. See events for async handling:
client.startServerAsync(launchParameters: LaunchParameters);
Start a server synchronously, resolves to a ServerStateChange object representing the event of server starting up:
client.startServerSync(launchParameters: LaunchParameters);
Stop a server asynchronously, resolves to a Status object.
client.stopServerAsync(stopAttributes: StopServerAttributes);
Stop a server synchronously, resolves to a ServerStateChange object representing the event of server stopping:
client.stopServerSync(stopAttributes: StopServerAttributes);
The asynchronous methods use several events to handle the response from the server. The client has the following methods to subscribe to these events.
// handle adding discovery paths
client.onDiscoveryPathAdded(listener: (arg: DiscoveryPath) => {
// your logic here
});
// handle removing discovery paths
client.onDiscoveryPathRemoved(listener: (arg: DiscoveryPath) => {
// your logic here
});
// handle adding servers
client.onServerAdded(listener: (arg: ServerHandle) => {
// your logic here
});
// handle removing servers
client.onServerRemoved(listener: (arg: ServerHandle) => {
// your logic here
});
// handle server state changes, useful for starting or stopping servers
client.onServerStateChange(listener: (arg: ServerStateChange) => {
// your logic here
});
// handle incoming output from a server
client.onServerOutputAppended(listener: (arg: ServerProcessOutput) => {
// your logic here
});
// handle server's attributes changing
client.onServerAttributeChange(listener: (arg: ServerHandle) => {
// your logic here
});
// handle server process creation
client.onServerProcessCreated(listener: (arg: ServerProcess) => {
// your logic here
});
// handle server process termination
client.onServerProcessTerminated(listener: (arg: ServerProcess) => {
// your logic here
});