1
0

Added CI build

This commit is contained in:
2025-08-25 20:31:34 +02:00
parent e1d497373b
commit 4656814c5f
5 changed files with 218 additions and 7 deletions

View File

@@ -18,7 +18,7 @@ namespace AMWD.Net.Api.Fritz.CallMonitor
private bool _isDisposed;
private ILogger? _logger;
private readonly ReconnectTcpClient _client;
private readonly ReconnectTcpClient _tcpClient;
private readonly CancellationTokenSource _disposeCts;
private Task _monitorTask = Task.CompletedTask;
@@ -39,10 +39,10 @@ namespace AMWD.Net.Api.Fritz.CallMonitor
throw new ArgumentOutOfRangeException(nameof(port));
_disposeCts = new CancellationTokenSource();
_client = new ReconnectTcpClient(host, port) { OnConnected = OnConnected };
_tcpClient = new ReconnectTcpClient(host, port) { OnConnected = OnConnected };
// Start the client in the background
_client.StartAsync(_disposeCts.Token).Forget();
_tcpClient.StartAsync(_disposeCts.Token).Forget();
}
/// <summary>
@@ -62,7 +62,7 @@ namespace AMWD.Net.Api.Fritz.CallMonitor
set
{
_logger = value;
_client.Logger = value;
_tcpClient.Logger = value;
}
}
@@ -85,7 +85,7 @@ namespace AMWD.Net.Api.Fritz.CallMonitor
catch
{ }
_client.Dispose();
_tcpClient.Dispose();
_disposeCts.Dispose();
GC.SuppressFinalize(this);
@@ -93,6 +93,8 @@ namespace AMWD.Net.Api.Fritz.CallMonitor
private Task OnConnected(ReconnectTcpClient client)
{
Logger?.LogTrace($"Client connected");
_monitorTask = Task.Run(async () =>
{
try

View File

@@ -1,10 +1,51 @@
# FRITZ!Box Call Monitor
You can use this small library to connect to the FRITZ!Box Call Monitor and receive live call events.
## Router preparation
Call `#96*5*` to enable the endpoint in your FRITZ!Box.
Call `#96*4*` to disable it again.
## In your code
```csharp
using (var client = new CallMonitorClient(host, port))
{
client.OnEvent += (sender, e) =>
{
switch (e.Event)
{
case EventType.Ring:
Console.WriteLine($"{e.Timestamp:yyyy-MM-dd HH:mm:ss} | #{e.ConnectionId} | Incoming Call from {e.CallerNumber} to {e.CalleeNumber}");
break;
case EventType.Connect:
Console.WriteLine($"{e.Timestamp:yyyy-MM-dd HH:mm:ss} | #{e.ConnectionId} | Call connected to {e.CallerNumber}");
break;
case EventType.Disconnect:
Console.WriteLine($"{e.Timestamp:yyyy-MM-dd HH:mm:ss} | #{e.ConnectionId} | Call disconnected after {e.Duration}");
break;
case EventType.Call:
Console.WriteLine($"{e.Timestamp:yyyy-MM-dd HH:mm:ss} | #{e.ConnectionId} | Outgoing Call from {e.CalleeNumber} to {e.CallerNumber}");
break;
}
};
// Wait to terminate.
}
```
---
Published under MIT License (see [choose a license]).
[![Buy me a Coffee](https://shields.am-wd.de/badge/PayPal-Buy_me_a_Coffee-yellow?style=flat&logo=paypal)](https://link.am-wd.de/donate)
[![Buy me a Coffee](https://shields.io/badge/PayPal-Buy_me_a_Coffee-yellow?style=flat&logo=paypal)](https://link.am-wd.de/donate)
[choose a license]: https://choosealicense.com/licenses/mit/