mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 12:32:03 -04:00
Stop spamming subscriptions when already online
This commit is contained in:
@@ -25,6 +25,7 @@ public class Clashgg : IDisposable
|
|||||||
private Task? _heartbeatTask;
|
private Task? _heartbeatTask;
|
||||||
// There's no smarts, it just does 30-second pings
|
// There's no smarts, it just does 30-second pings
|
||||||
private TimeSpan _heartbeatInterval = TimeSpan.FromSeconds(30);
|
private TimeSpan _heartbeatInterval = TimeSpan.FromSeconds(30);
|
||||||
|
private bool _isOnline = false;
|
||||||
|
|
||||||
public Clashgg(string? proxy = null, CancellationToken? cancellationToken = null)
|
public Clashgg(string? proxy = null, CancellationToken? cancellationToken = null)
|
||||||
{
|
{
|
||||||
@@ -119,12 +120,13 @@ public class Clashgg : IDisposable
|
|||||||
{
|
{
|
||||||
var packet = JsonSerializer.Deserialize<List<JsonElement>>(message.Text);
|
var packet = JsonSerializer.Deserialize<List<JsonElement>>(message.Text);
|
||||||
if (packet == null) throw new InvalidOperationException("Caught a null when deserializing Clash.gg packet");
|
if (packet == null) throw new InvalidOperationException("Caught a null when deserializing Clash.gg packet");
|
||||||
if (packet[0].GetString() == "online")
|
if (packet[0].GetString() == "online" && !_isOnline)
|
||||||
{
|
{
|
||||||
_logger.Info("Received online packet from Clash.gg. Subscribing to Plinko, Mines and Keno");
|
_logger.Info("Received online packet from Clash.gg. Subscribing to Plinko, Mines and Keno");
|
||||||
_wsClient.Send("[\"subscribe\",\"plinko\"]");
|
_wsClient.Send("[\"subscribe\",\"plinko\"]");
|
||||||
_wsClient.Send("[\"subscribe\",\"mines\"]");
|
_wsClient.Send("[\"subscribe\",\"mines\"]");
|
||||||
_wsClient.Send("[\"subscribe\",\"keno\"]");
|
_wsClient.Send("[\"subscribe\",\"keno\"]");
|
||||||
|
_isOnline = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user