nikeee / TeamSpeak3QueryApi

.NET wrapper for the TeamSpeak 3 Query API
https://nikeee.github.io/TeamSpeak3QueryAPI
GNU General Public License v3.0
60 stars 16 forks source link

Feature Request: Automatic Keep-Alive #65

Closed nikeee closed 3 years ago

nikeee commented 4 years ago

See #64 for the need of this.

Option 1:

Use System.Timers.Timer Pros:

Note:

Option 2:

Timeout in the response queue. Pros:

Option N

[your suggestion here (comment on this issue)]

General implementation notes:

Arefu commented 4 years ago

Looks like I was wrong, Timers were introduced in .NET Standard 2.0.

I'll take a look at implementing it internally, I agree it should mostly be transparent, but there should be ways to disable it in case the user already has their own solution in place.

Des1re7 commented 4 years ago

I have implemented this as a simple task:

private async Task KeepAlive(CancellationToken cancellationToken, TimeSpan delay)
{
    while (!cancellationToken.IsCancellationRequested)
    {
        await TeamSpeak.WhoAmI();
        await Task.Delay(delay, cancellationToken);
    }
}
nikeee commented 3 years ago

Solved via #67