pamoja for TypeScript - v0.2.0
    Preparing search index...

    Class CoapServer

    A CoAP server: the end that nodes send their readings to and observe their commands on.

    A PUT or POST to a path matching one of its subscribe filters is answered 2.04 Changed and delivered to recv, and one to any other path 4.04 Not Found. send sets a resource's state, which a GET reads and every observer is notified of. send does not wait for a recv that is waiting, so a gateway sends commands while it listens for readings.

    Index
    • Creates a server that will listen on a local address, such as 0.0.0.0:5683, or port 0 for a free one.

      Parameters

      • bind: string

      Returns CoapServer

    • get isConnected(): boolean

      Whether the server holds a bound socket.

      Returns boolean

    • get localPort(): number | null

      The port the server listens on, which names the one the system chose for port 0, or null while it is not connected.

      Returns number | null

    • Binds the socket and starts answering requests. Rejects when the address cannot be bound.

      Returns Promise<void>

    • Closes the socket, keeping the resources and filters.

      Returns Promise<void>

    • Counts the clients observing a resource.

      Parameters

      • path: string

      Returns number

    • Waits for the next reading sent to a path the server takes. Rejects when the server is not connected.

      Parameters

      • OptionaltimeoutMs: number | null

        how long to wait before rejecting; a reading that arrives later waits for the next receive.

      Returns Promise<TransportMessage | null>

    • Sets a resource's state and notifies every observer of it: bytes, or text such as a command. Rejects when the server is not connected.

      Parameters

      • path: string
      • payload: string | Buffer<ArrayBufferLike>

      Returns Promise<void>

    • Takes the readings sent to the paths a filter matches, with + for one level and # for the rest.

      Parameters

      • filter: string

      Returns Promise<void>