Skip to content

Commit 5528bcd

Browse files
docs: subtypes
1 parent fbc50ec commit 5528bcd

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ service or service instance.
2121
- Detects new and/or removed network interfaces
2222
- Supports multicasting on multiple network interfaces
2323
- Supports reverse address mapping
24+
- Supports service subtypes (features)
2425
- Handles legacy unicast queries, see #61
2526

2627
## Getting started

doc/articles/subtype.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Subtypes
2+
3+
Subtypes are used to define features implemented by a service instance. See
4+
[RFC 6763 - 7.1 Selective Instance Enumeration (Subtypes)](https://tools.ietf.org/html/rfc6763#section-7.1) for the details.
5+
6+
7+
## Finding service instances
8+
9+
[QueryServiceInstances](xref:Makaretu.Dns.ServiceDiscovery.QueryServiceInstances*) is used to find the
10+
all the instances of a service with a specific feature.
11+
The [ServiceInstanceDiscovered](xref:Makaretu.Dns.ServiceDiscovery.ServiceInstanceDiscovered) event is raised
12+
each time a service instance is discovered.
13+
14+
```csharp
15+
using Makaretu.Dns;
16+
17+
var sd = new ServiceDiscovery();
18+
sd.ServiceInstanceDiscovered += (s, e) =>
19+
{
20+
Console.WriteLine($"service instance '{e.ServiceInstanceName}'");
21+
};
22+
sd.QueryServiceInstances("_myservice", "apiv2");
23+
```
24+
25+
## Advertising
26+
27+
Create a [ServiceProfile](xref:Makaretu.Dns.ServiceProfile) with a feature
28+
and then [Advertise](xref:Makaretu.Dns.ServiceDiscovery.Advertise*) it. Any queries for the service or
29+
service instance will be answered with information from the profile.
30+
31+
```csharp
32+
using Makaretu.Dns;
33+
34+
var profile = new ServiceProfile("x", "_myservice._udp", 1024);
35+
profile.Subtypes.Add("apiv2");
36+
var sd = new ServiceDiscovery();
37+
sd.Advertise(profile);
38+
```

doc/articles/toc.yml

+3
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
href: ms.md
55
- name: Service Discovery
66
href: sd.md
7+
items:
8+
- name: Subtypes
9+
href: subtype.md
710
- name: Class Reference
811
href: ../api/Makaretu.Dns.yml

0 commit comments

Comments
 (0)