forked from sokarovski/bonjour
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TypeScript typing, dependency updates, and housekeeping. (#25)
- Loading branch information
Showing
4 changed files
with
1,544 additions
and
1,015 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { SocketOptions } from "dgram"; | ||
|
||
export type BonjourFindOptions = { | ||
type: string; | ||
subtypes?: string[]; | ||
protocol?: "tcp" | "udp"; | ||
txt?: Record<string, any>; | ||
}; | ||
|
||
export interface BonjourService { | ||
name: string; | ||
type: string; | ||
protocol: "tcp" | "udp"; | ||
host: string; | ||
port: number; | ||
addresses: string[]; | ||
txt: Record<string, string>; | ||
rawTxt?: Buffer; | ||
} | ||
|
||
export interface MulticastOptions extends SocketOptions { | ||
multicastAddress?: string; | ||
multicastInterface?: string; | ||
multicastTTL?: number; | ||
reuseAddr?: boolean; | ||
} | ||
|
||
export class Browser { | ||
start(): void; | ||
stop(): void; | ||
update(): void; | ||
on(event: "up" | "down", listener: (service: BonjourService) => void): this; | ||
} | ||
|
||
export class Advertisement { | ||
stop(): void; | ||
start(): void; | ||
update(txt: Record<string, string>): void; | ||
on(event: "error", listener: (err: Error) => void): this; | ||
} | ||
|
||
export interface PublishOptions { | ||
name: string; | ||
type: string; | ||
subtypes?: string[]; | ||
port: number; | ||
host?: string; | ||
txt?: Record<string, string>; | ||
protocol?: "tcp" | "udp"; | ||
} | ||
|
||
export default class Bonjour { | ||
constructor(options?: MulticastOptions); | ||
|
||
publish(options: PublishOptions): Advertisement; | ||
unpublishAll(callback?: () => void): void; | ||
find( | ||
options: BonjourFindOptions, | ||
onUp?: (service: BonjourService) => void | ||
): Browser; | ||
findOne( | ||
options: BonjourFindOptions, | ||
callback: (service: BonjourService) => void | ||
): Browser; | ||
destroy(): void; | ||
} |
Oops, something went wrong.