Class SockDaemonClient<Request, Response>Abstract

Override this class to create a Client that can talk to the SockDaemonServer you've created.

Note that the static serviceName and daemonScript getters MUST be defined on the extended class, referencing the service name and location of the daemon script.

Type Parameters

Hierarchy

  • SockDaemonClient

Constructors

Properties

#clientID: string = ...
#connected: boolean = false
#connection?: Socket
#daemonScript: string
#debug: boolean
#didPing: boolean = false
#execArgv: string[]
#logFile: string
#msgID: number = 0
#mtimeCheckP?: Promise<boolean>
#mtimeFile: string
#path: string
#pidFile: string
#ping?: Ping
#pingTimer?: Timeout
#reader?: Reader
#requests: Map<string, ClientRequest<Request, Response>> = ...
#serviceName: string
#socket: string

Accessors

  • get connected(): boolean
  • True if currently connected to the daemon service

    Returns boolean

  • get connection(): undefined | Socket
  • True if the client is currently connected

    Returns undefined | Socket

  • get execArgv(): string[]
  • The execArgv that is used when spawning the daemon script.

    Returns string[]

  • get logFile(): string
  • Path where daemon logs are written

    Returns string

  • get mtimeFile(): string
  • Path where the daemonScript mtime is written

    Returns string

  • get path(): string
  • The folder where this daemon service stores stuff

    Returns string

  • get pidFile(): string
  • File containing the daemon process ID

    Returns string

  • get socket(): string
  • Path to the socket used by this service

    Returns string

  • get daemonScript(): string | URL
  • The location of the daemon script that starts up the SockDaemonServer service that this client talks to.

    Returns string | URL

  • get serviceName(): string
  • The name of the service. Must match the value set in the SockDaemonServer class this talks to.

    Returns string

Methods

  • Returns Promise<boolean>

  • Returns Promise<void>

  • Parameters

    • chunk: Buffer

    Returns void

  • Drop all pending requests

    Returns void

  • Immediately disconnect from the server. Pending requests will be replayed on the next connection, unless clear() is called.

    Returns void

  • Set to check that a response is valid

    Parameters

    • msg: any

    Returns msg is Response

  • Kill the server, if it is running.

    Attempts to send a SIGHUP to allow for graceful shutdown, but this is not possible on Windows.

    Returns Promise<void>

  • Send a PING message to the server. This can be useful when you want to start the daemon, without making any specific request.

    Returns Promise<Omit<Ping, "PING"> & {
        PING: "PONG";
        pid: number;
    } & {
        duration: number;
    }>

  • Send a request. The id property is made optional, because it will be overridden anyway by a generated message ID. Starts the daemon script automatically if not already running, and connects if needed.

    If an AbortSignal is provided, then the request will be dropped on an abort signal, and the promise rejected with the abort reason, if it has not already been resolved.

    Parameters

    • msg: Omit<Ping, "id">
    • Optional signal: AbortSignal

    Returns Promise<Omit<Ping, "PING"> & {
        PING: "PONG";
        pid: number;
    } & {
        duration: number;
    }>

  • Parameters

    • msg: Omit<Request, "id">
    • Optional signal: AbortSignal

    Returns Promise<Response>

Generated using TypeDoc