Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LocalServer

A static singleton class which manages a local TCP server.

Hierarchy

  • LocalServer

Index

Properties

Static Private emitter

emitter: EventEmitter

Static Private initialized

initialized: boolean = false

Static Private server

server: Server

Static Private socketIdCounter

socketIdCounter: number = 0

Static Private sockets

sockets: SocketWrapper[]

Methods

Static Private getNextSocketId

  • getNextSocketId(): number

Static init

  • init(port?: number): void
  • Initializes the Local Server and begins listening on the specified port.

    Parameters

    • Optional port: number

      The port to listen for connections on.

    Returns void

Static on

  • on(event: "message", listener: function): EventEmitter
  • Attaches an event listener to the Local Server.

    Parameters

    • event: "message"

      The name of the event to listen for. Available events are 'message'.

    • listener: function

      The callback to invoke when the event is fired.

        • (message: string): void
        • Parameters

          • message: string

          Returns void

    Returns EventEmitter

Static Private onConnection

  • onConnection(socket: Socket): void

Static write

  • write(message: string | Buffer): void
  • Writes data to all connected sockets. If message is not a buffer, it will be converted to a buffer using utf8 encoding. If it is a buffer, it will not be affected.

    Parameters

    • message: string | Buffer

      The message to send.

    Returns void

Generated using TypeDoc