@collight/dns-sd
    Preparing search index...

    Class ServiceType

    Represents a network service type with optional protocol and subtype.

    Index

    Methods

    • Serializes the ServiceType instance into a string following DNS-SD format.

      Returns string

      The serialized service type string.

      const svc = new ServiceType('http', 'tcp');
      console.log(svc.toString()); // _http._tcp

      const svcWithSubtype = new ServiceType('http', 'tcp', 'printer');
      console.log(svcWithSubtype.toString()); // _printer._sub._http._tcp
    • Parses a service type string into a ServiceType instance.

      Expected formats include:

      • "_http._tcp"
      • "_printer._sub._http._tcp" (a subtype "printer" of "_http._tcp")

      Parameters

      • input: string

        The service type string to parse.

      Returns ServiceType

      The parsed ServiceType instance.

      ServiceType.fromString('_http._tcp');
      // { name: "http", protocol: "tcp", subtype: undefined }

      ServiceType.fromString('_printer._sub._http._tcp');
      // { name: "http", protocol: "tcp", subtype: "printer" }