Update react-native-zeroconf types to v0.11 (#41284)

This commit is contained in:
Peter Matta 2020-01-01 00:22:10 +01:00 committed by Ryan Cavanaugh
parent 90a56d675d
commit 74fa9e11a4
2 changed files with 28 additions and 1 deletions

View File

@ -1,4 +1,4 @@
// Type definitions for react-native-zeroconf 0.9
// Type definitions for react-native-zeroconf 0.11
// Project: https://github.com/Apercu/react-native-zeroconf#readme
// Definitions by: Peter Matta <https://github.com/mattapet>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@ -80,6 +80,31 @@ export default class Zeroconf extends EventEmitter {
*/
addDeviceListeners(): void;
/**
* Publish a service.
*
* @description This adds a service for the current device to the
* discoverable services on the network.
*
* @param type Should be both type of the service, for example 'http'.
* @param protocol Should be protocol of the service, for example 'tcp'.
* @param domain Should be the domain the service is sitting on, dot
* suffixed, for example `'local.'`. Defaults to `'local'`.
* @param name should be unique to the device, often the device name.
* @param port should be an integer between 0 and 65535.
*/
publishService(type: string, protocol: string, domain?: string, name?: string, port?: number): void;
/**
* Unpublish a service.
*
* @description This removes a service from those discoverable on the
* network.
*
* @param name should be the name used when publishing the service.
*/
unpublishService(name: string): void;
on(e: 'start' | 'stop' | 'update', listener: () => any): this;
/**

View File

@ -11,6 +11,8 @@ zeroconf.on('remove', (name: string) => console.log(`[Remove] '${name}'`));
zeroconf.on('update', () => console.log('[Update]'));
zeroconf.on('error', (error: Error) => console.log(`[Error] ${error}`));
zeroconf.publishService('http', 'tcp', 'local.', 'test-device', 3000);
zeroconf.scan('http', 'tcp', 'local.');
const services = zeroconf.getServices();
for (const serviceName in services) {