Skip to content

Commit 96e3be3

Browse files
committed
add default implementation for IMuninNodeListenerFactory
1 parent a119aed commit 96e3be3

File tree

3 files changed

+28
-25
lines changed

3 files changed

+28
-25
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
2+
// SPDX-License-Identifier: MIT
3+
using System.Net;
4+
using System.Threading;
5+
using System.Threading.Tasks;
6+
7+
namespace Smdn.Net.MuninNode.Transport;
8+
9+
internal sealed class MuninNodeListenerFactory : IMuninNodeListenerFactory {
10+
public static readonly MuninNodeListenerFactory Instance = new();
11+
12+
public ValueTask<IMuninNodeListener> CreateAsync(
13+
EndPoint endPoint,
14+
IMuninNode node,
15+
CancellationToken cancellationToken
16+
)
17+
#pragma warning disable CA2000
18+
=> new(
19+
new MuninNodeListener(
20+
endPoint: endPoint,
21+
logger: null,
22+
serviceProvider: null
23+
)
24+
);
25+
#pragma warning restore CA2000
26+
}

src/Smdn.Net.MuninNode/Smdn.Net.MuninNode/LocalNode.Create.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected override EndPoint GetLocalEndPointToBind()
5858
port: port
5959
);
6060

61-
private new sealed class ListenerFactory(ILogger? logger) : IMuninNodeListenerFactory {
61+
private sealed class ListenerFactory(ILogger? logger) : IMuninNodeListenerFactory {
6262
public ValueTask<IMuninNodeListener> CreateAsync(
6363
EndPoint endPoint,
6464
IMuninNode node,
Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
// SPDX-FileCopyrightText: 2023 smdn <smdn@smdn.jp>
22
// SPDX-License-Identifier: MIT
3-
using System.Net;
4-
using System.Threading;
5-
using System.Threading.Tasks;
6-
73
using Microsoft.Extensions.Logging;
84

95
using Smdn.Net.MuninNode.Transport;
@@ -35,29 +31,10 @@ protected LocalNode(
3531
ILogger? logger
3632
)
3733
: base(
38-
listenerFactory: listenerFactory ?? ListenerFactory.Instance,
34+
listenerFactory: listenerFactory ?? MuninNodeListenerFactory.Instance,
3935
accessRule: accessRule,
4036
logger: logger
4137
)
4238
{
4339
}
44-
45-
private sealed class ListenerFactory : IMuninNodeListenerFactory {
46-
public static readonly ListenerFactory Instance = new();
47-
48-
public ValueTask<IMuninNodeListener> CreateAsync(
49-
EndPoint endPoint,
50-
IMuninNode node,
51-
CancellationToken cancellationToken
52-
)
53-
#pragma warning disable CA2000
54-
=> new(
55-
new MuninNodeListener(
56-
endPoint: endPoint,
57-
logger: null,
58-
serviceProvider: null
59-
)
60-
);
61-
#pragma warning restore CA2000
62-
}
6340
}

0 commit comments

Comments
 (0)