-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '3.9-dev' of https://github.com/project-fika/Fika-Plugin …
…into 3.9-dev
- Loading branch information
Showing
10 changed files
with
730 additions
and
664 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Fika.Core.Networking.Http; | ||
using Fika.Core.Networking.Http.Models; | ||
using System.Collections; | ||
using System.Threading.Tasks; | ||
using UnityEngine; | ||
|
||
namespace Fika.Core.Coop.Components | ||
{ | ||
public class FikaPinger : MonoBehaviour | ||
{ | ||
private Coroutine pingRoutine; | ||
|
||
public void StartPingRoutine() | ||
{ | ||
pingRoutine = StartCoroutine(PingServer()); | ||
} | ||
|
||
public void StopPingRoutine() | ||
{ | ||
if (pingRoutine != null) | ||
{ | ||
StopCoroutine(pingRoutine); | ||
pingRoutine = null; | ||
} | ||
} | ||
|
||
private IEnumerator PingServer() | ||
{ | ||
PingRequest pingRequest = new(); | ||
|
||
while (true) | ||
{ | ||
Task pingTask = FikaRequestHandler.UpdatePing(pingRequest); | ||
while (!pingTask.IsCompleted) | ||
{ | ||
yield return null; | ||
} | ||
yield return new WaitForSeconds(30); | ||
} | ||
} | ||
|
||
private void OnDestroy() | ||
{ | ||
StopPingRoutine(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
using Fika.Core.Coop.Components; | ||
using Fika.Core.Coop.Matchmaker; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Fika.Core.Networking.Http.Models | ||
{ | ||
[DataContract] | ||
public struct PingRequest | ||
{ | ||
[DataMember(Name = "serverId")] | ||
public string ServerId; | ||
[DataContract] | ||
public struct PingRequest | ||
{ | ||
[DataMember(Name = "serverId")] | ||
public string ServerId; | ||
|
||
public PingRequest() | ||
{ | ||
ServerId = CoopHandler.GetServerId(); | ||
} | ||
} | ||
public PingRequest() | ||
{ | ||
ServerId = MatchmakerAcceptPatches.GetGroupId(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters