-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsolePublisher.cs
More file actions
46 lines (37 loc) · 1.45 KB
/
ConsolePublisher.cs
File metadata and controls
46 lines (37 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
namespace LabTracker;
/// <summary>
/// Console implementation of the IPublisher interface for testing/debugging.
/// </summary>
public class ConsolePublisher : IPublisher
{
private readonly ILogger<ConsolePublisher> _logger;
public ConsolePublisher(ILogger<ConsolePublisher> logger)
{
_logger = logger;
}
public bool IsConnected => true; // Console is always "connected"
public Task InitializeAsync()
{
_logger.LogInformation("Console publisher initialized");
return Task.CompletedTask;
}
public Task PublishClientsAsync(string apHostname, List<string> connectedClients, List<string> disconnectedClients)
{
var timestamp = DateTimeOffset.UtcNow.ToString("yyyy-MM-dd HH:mm:ss");
if (connectedClients.Count > 0)
{
Console.WriteLine($"[{timestamp}] CONNECTED to {apHostname} ({connectedClients.Count}): {string.Join(", ", connectedClients)}");
}
if (disconnectedClients.Count > 0)
{
Console.WriteLine($"[{timestamp}] DISCONNECTED from {apHostname} ({disconnectedClients.Count}): {string.Join(", ", disconnectedClients)}");
}
_logger.LogDebug("Published client events for AP {ap} to console", apHostname);
return Task.CompletedTask;
}
public ValueTask DisposeAsync()
{
_logger.LogInformation("Console publisher disposed");
return ValueTask.CompletedTask;
}
}