Implementation of the QOTD protocol for .NET in C#.
- Supports TCP and UDP servers and clients.
- Supports IPv4 and IPv6.
- Integrates nicely with hosted applications.
- Customizable quotes with
IQuoteProvider. - Thread-safe.
Install via NuGet: QOTD.NET.
<PackageReference Include="QOTD.NET" Version="TODO" />The client is able to request one or more quotes from a server.
HostApplicationBuilder appBuilder = new HostApplicationBuilder();
appBuilder.Services
.AddQotdClient(client =>
{
client.Mode = QotdClientMode.Udp; // Tcp, Udp
client.Host = IPAddress.IPv6Loopback;
client.Port = 17;
});
IHost app = appBuilder.Build();
await app.StartAsync();
QotdClient client = app.Services.GetRequiredService<QotdClient>();
string quote = await client.RequestQuoteAsync();The server hosts quotes for clients to connect to.
HostApplicationBuilder appBuilder = new HostApplicationBuilder();
appBuilder.Services
.AddDailyQuoteProvider(options =>
{
options.RolloverTime = TimeSpan.Parse("22:22:00");
options.TimeZone = "America/New_York";
options.Quotes =
[
"Some random quote",
"Another random quote",
"A third qoute"
];
})
.AddQotdServer(server =>
{
server.Mode = QotdServerMode.Both; // Tcp, Udp, Both
});
IHost app = appBuilder.Build();
await app.RunAsync();