From 74fa9e11a4b2ea985c5d22dfece928221e78e0e9 Mon Sep 17 00:00:00 2001 From: Peter Matta Date: Wed, 1 Jan 2020 00:22:10 +0100 Subject: [PATCH] Update react-native-zeroconf types to v0.11 (#41284) --- types/react-native-zeroconf/index.d.ts | 27 ++++++++++++++++++- .../react-native-zeroconf-tests.ts | 2 ++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/types/react-native-zeroconf/index.d.ts b/types/react-native-zeroconf/index.d.ts index ae1e8543e2..f8c92dc65d 100644 --- a/types/react-native-zeroconf/index.d.ts +++ b/types/react-native-zeroconf/index.d.ts @@ -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 // 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; /** diff --git a/types/react-native-zeroconf/react-native-zeroconf-tests.ts b/types/react-native-zeroconf/react-native-zeroconf-tests.ts index 423a8f1bc5..01894422e5 100644 --- a/types/react-native-zeroconf/react-native-zeroconf-tests.ts +++ b/types/react-native-zeroconf/react-native-zeroconf-tests.ts @@ -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) {