Jacktrip
- Introduction
- Functions
- public getJacktripPaths()
- public isJacktripRunning()
- public startJacktripHubClient()
- public startJacktripHubClientAsync()
- public startJacktripHubServer()
- public startJacktripHubServerAsync()
- public startJacktripP2PClient()
- public startJacktripP2PClientAsync()
- public startJacktriptP2PMultipleClientsAsync()
- public startJacktripP2PServer()
- public startJacktripP2PServerAsync()
Introduction
This module provides logic for managing the Jacktrip process on a host system. It offers functions to check its status, start it with configurable parameters, and ensure its successful initialization.
Functions
getJacktripPaths()
export const getJacktripPaths = (): JacktripPaths => { ... }
Returns
- An object of type
JacktripPaths
based on the operating system where the code is executed.
Behavior
- It uses
process.platform
to determine the OS:win32
: CallsjacktripWinPaths()
darwin
: CallsjacktripDarwinPaths()
- Any other platform will default to Linux and call
jacktripLinuxPaths()
.
isJacktripRunning()
export const isJacktripRunning = (): Promise<boolean>
This function checks if the JackTrip daemon is currently running on the system. It returns a Promise that resolves to a boolean value indicating the status.
Returns
Promise<boolean>
: Resolves to true
if JackTrip is running, otherwise resolves to false
.
Example
isJacktripRunning()
.then((isRunning) => {
if (isRunning) {
console.log("JackTrip is running.");
} else {
console.log("JackTrip is not running.");
}
})
.catch((error) => {
console.error("An error occurred while checking JackTrip status:", error);
});
startJacktripHubClient()
export const startJacktripHubClient = (
jacktripHubClientParams: JacktripHubClientParams,
{ onLog }: OptionalParams
): RunningCommand
Initializes and starts a Jacktrip Hub Client using the provided parameters. If successful, it spawns a new process for the client.
Parameters
-
jacktripHubClientParams
: An object from type JacktripHubClientParams joined with JacktripParams. -
optionalParams
: Additional parameters, including logging functionality from type OptionalParams
Returns
RunningCommand
: An object containing from type RunningCommand.
startJacktripHubClientAsync()
export const startJacktripHubClientAsync = (
jacktripHubClientParams: JacktripHubClientParams,
optionalParams: OptionalParams
): Promise<RunningCommand>
Asynchronously starts a Jacktrip Hub Client and returns a Promise that resolves once the client is fully started.
Parameters
-
jacktripHubClientParams
: An object from type JacktripHubClientParams joined with JacktripParams. -
optionalParams
: Additional parameters, including logging functionality from type OptionalParams
Returns
RunningCommand
: An object containing from type RunningCommand.
startJacktripHubServer()
export const startJacktripHubServer = (
jacktripHubServerParams: JacktripHubServerParams,
{ onLog }: OptionalParams
): RunningCommand
Starts a Jacktrip Hub Server using provided parameters and configurations. Handles command-line parameter assembly and execution of the Jacktrip server process.
Parameters
-
jacktripHubServerParams
: An object from type JacktripHubServerParams joined with JacktripParams. -
optionalParams
: Additional parameters, including logging functionality from type OptionalParams
Returns
RunningCommand
: An object containing from type RunningCommand.
Errors
-
Throws
HubPatchModeNotValidException
if the providedhubPatchMode
is invalid. -
Throws
StartJacktripFailedException
if the Jacktrip server fails to start.
startJacktripHubServerAsync()
export const startJacktripHubServerAsync = (
jacktripHubServerParams: JacktripHubServerParams,
optionalParams: OptionalParams
): Promise<RunningCommand>
Asynchronously starts a Jacktrip Hub Server and waits for the server to be fully initialized.
Parameters
-
jacktripHubServerParams
: An object from type JacktripHubServerParams joined with JacktripParams. -
optionalParams
: Additional parameters, including logging functionality from type OptionalParams
Returns
Promise<RunningCommand>
: Resolves to aRunningCommand
object once the server has started.
startJacktripP2PClient()
export const startJacktripP2PClient = (
jacktripP2PClientParams: JacktripP2PClientParams,
{ onLog }: OptionalParams
): RunningCommand
Starts a Jacktrip P2P Client with provided parameters.
Parameters
-
jacktripP2PClientParams
: An object from type JacktripP2PClientParams joined with JacktripP2PServerParams. -
optionalParams
: Additional parameters, including logging functionality from type OptionalParams
Returns
RunningCommand
: An object containing from type RunningCommand.
startJacktripP2PClientAsync()
export const startJacktripP2PClientAsync = (
jacktripP2PClientParams: JacktripP2PClientParams,
optionalParams: OptionalParams
): Promise<RunningCommand>
Starts a Jacktrip P2P Client asynchronously and waits for the server to fully start.
Parameters
-
jacktripP2PClientParams
: An object from type JacktripP2PClientParams joined with JacktripP2PServerParams. -
optionalParams
: Additional parameters, including logging functionality from type OptionalParams
Returns
Promise<RunningCommand>
: Resolves to aRunningCommand
object once the server has started.
startJacktriptP2PMultipleClientsAsync()
export const startJacktriptP2PMultipleClientsAsync = (
jacktripP2PClientParams: Omit<JacktripP2PClientParams, 'localPort' | 'clientName' | 'host'>,
clients: JacktripP2PClient[]
): Promise<RunningCommand[]>
Starts multiple Jacktrip P2P Clients asynchronously based on an array of clients.
Parameters
-
jacktripP2PClientParams
: An object from type JacktripP2PClientParams joined with JacktripP2PServerParams. -
clients
: An array ofJacktripP2PClient
objects, each defininglocalPort
,clientName
, andhost
.
Returns
Promise<RunningCommand>
: Resolves to aRunningCommand
object once the server has started.
startJacktripP2PServer()
export const startJacktripP2PServer = (
jacktripP2PServerParams: JacktripP2PServerParams,
{ onLog }: OptionalParams
): RunningCommand
Starts a Jacktrip Peer-to-Peer Server by spawning a process with defined parameters. It validates and prepares command-line arguments for launching the Jacktrip server.
Parameters
-
jacktripP2PServerParams
: An object from type JacktripP2PServerParams. -
optionalParams
: Additional parameters, including logging functionality from type OptionalParams
Returns
RunningCommand
: An object containing from type RunningCommand.
Throws
- BitRateNotValidException: If the provided bit rate is invalid.
- StartJacktripFailedException: If the server fails to start, an exception containing the error message is thrown.
startJacktripP2PServerAsync()
export const startJacktripP2PServerAsync = (
jacktripP2PServerParams: JacktripP2PServerParams,
optionalParams: OptionalParams
): Promise<RunningCommand>
Starts a Jacktrip Peer-to-Peer Server asynchronously, allowing the application to continue without waiting for the server to fully start.
Parameters
-
jacktripP2PServerParams
: An object from type JacktripP2PServerParams. -
optionalParams
: Additional parameters, including logging functionality from type OptionalParams
Returns
Promise<RunningCommand>
: Resolves to aRunningCommand
object once the server has started.