The official build of the LatencyGG C# Library. To see an example of this library in action, take a look at the Latency.GG Unity Demo.
$ dotnet add package LatencyGG-DotNETA C# library for latency measurements using the LatencyGG network.
See the example for recommended usage.
First create an instance of LatencyGG specifying the type of AF (eINET for IPv4 eINET6 for IPV6) and the timeout limit for pings.
LatencyGG.LatencyGG latency = new LatencyGG.LatencyGG(LatencyGG.AF.eINET, 2000);
Then create instances of DataPing, specifying the target_ip (beacon address), own_ip (user public ip), ident(as provided by the Latency.gg Client API), token(if provided by the Latency.gg Client API, "" if not), and dpversion (3 if token supplied 2 if not).
LatencyGG.DataPing dataPing = new LatencyGG.DataPing(targetIp, ownIp, ident, token, dpversion);
Next, add all of the pings you wish to run simultaneously (for accurate measurements don't run more than 10 measurements simultaneously).
latency.Add(ping1);
Finally, run the measurement.
latency.Run();
If you need to terminate a running measurement before it is complete, discarding the measurements call Kill().
latency.Kill();
To check if all measurements are complete you can poll the IsComplete() method.
if (latency.IsComplete()) {
// Do something
}
Results can be retrieved via a Map-like interface
LatencyGG.DataPing pingResult = latency[targetIp];
Console.Write(pingResult.GetStats().mRtt.ToString());