Unofficial CardLife revival project, pronounced like "celery"
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CLreEnforcer.cs 1.0KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System.Collections;
  2. using UnityEngine;
  3. namespace CLre_server.API.Synergy
  4. {
  5. internal static class CLreEnforcer
  6. {
  7. private const float _waitTime = 10.0f;
  8. public static IEnumerator WaitABitForHandshakeThenKick(int playerId)
  9. {
  10. float elapsedTime = 0.0f;
  11. while (elapsedTime < _waitTime)
  12. {
  13. yield return null;
  14. elapsedTime += Time.deltaTime;
  15. }
  16. yield return null;
  17. if (Clients.IsConnected(playerId) && !Clients.IsCLreClient(playerId))
  18. {
  19. MainServer.UserVerification.Instance.DisconnectPlayer(playerId);
  20. }
  21. }
  22. internal static void Init()
  23. {
  24. if (CLre_server.CLre.Config.clre_clients_only)
  25. {
  26. MainServer.Server.Instance.PlayerConnect += (_, playerData) =>
  27. {
  28. WaitABitForHandshakeThenKick(playerData.PlayerId).Run();
  29. };
  30. }
  31. }
  32. }
  33. }