DCS World Typescript
    Preparing search index...

    Represents an HTTP server. This class encapsulates the functionality required for creating and managing an HTTP server, including binding to a network address, accepting client connections, and handling client requests.

    // Example of creating and starting an HttpServer with a handler which returns 200 for all requests
    const httpServer = new HttpServer('127.0.0.1', 8080, (req, res) => { res.status = 200; return res; });
    while(true) {
    httpServer.acceptNextClient();
    }

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Methods

    Constructors

    • Creates an instance of a HTTP server.

      Parameters

      • bindAddress: string

        The IP address or hostname the server will bind to.

      • port: number

        The port number the server will listen on.

      • handler: RequestHandler

        The request handler to be used when serving requests

      Returns HttpServer

    Properties

    The request handler to be used when serving requests

    logger: Logger
    server: TCP

    The underlying TCP server.

    Methods

    • Accepts the next client connection. When a client connects, it handles the client's request.

      Returns void

      // Accept and handle the next client
      httpServer.acceptNextClient();