refactor: unwrap MDNS namespace + self-reexport (#22968)
This commit is contained in:
@@ -3,11 +3,10 @@ import { Bonjour } from "bonjour-service"
|
||||
|
||||
const log = Log.create({ service: "mdns" })
|
||||
|
||||
export namespace MDNS {
|
||||
let bonjour: Bonjour | undefined
|
||||
let currentPort: number | undefined
|
||||
let bonjour: Bonjour | undefined
|
||||
let currentPort: number | undefined
|
||||
|
||||
export function publish(port: number, domain?: string) {
|
||||
export function publish(port: number, domain?: string) {
|
||||
if (currentPort === port) return
|
||||
if (bonjour) unpublish()
|
||||
|
||||
@@ -42,9 +41,9 @@ export namespace MDNS {
|
||||
bonjour = undefined
|
||||
currentPort = undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function unpublish() {
|
||||
export function unpublish() {
|
||||
if (bonjour) {
|
||||
try {
|
||||
bonjour.unpublishAll()
|
||||
@@ -56,5 +55,6 @@ export namespace MDNS {
|
||||
currentPort = undefined
|
||||
log.info("mDNS service unpublished")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export * as MDNS from "./mdns"
|
||||
|
||||
Reference in New Issue
Block a user