-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
167 additions
and
80 deletions.
There are no files selected for viewing
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
24 changes: 0 additions & 24 deletions
24
docs/content/SynicSugar.P2P/ConnectHub/PausePacketReceiver.md
This file was deleted.
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
24 changes: 24 additions & 0 deletions
24
docs/content/SynicSugar.P2P/ConnectHub/StopPacketReceiver.md
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,24 @@ | ||
+++ | ||
title = "StopPacketReceiver" | ||
weight = 3 | ||
+++ | ||
## StopPacketReceiver | ||
<small>*Namespace: SynicSugar.P2P* <br> | ||
*Class: ConnectHub* </small> | ||
|
||
public void StopPacketReceiver() | ||
|
||
|
||
### Description | ||
Stop just getting a packet from the receiving buffer. **To get a packet again, call *[StartPacketReceiver](../ConnectHub/startpacketreceiver)***.<br> | ||
|
||
|
||
```cs | ||
using SynicSugar.P2P; | ||
|
||
public class p2pSample { | ||
void ConnectHubSample(){ | ||
ConnectHub.Instance.StopPacketReceiver(); | ||
} | ||
} | ||
``` |
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
35 changes: 0 additions & 35 deletions
35
docs/content/SynicSugar.P2P/p2pConnectorForOtherAssembly.md
This file was deleted.
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
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,31 @@ | ||
+++ | ||
title = "ConnectionIsValid" | ||
weight = 6 | ||
+++ | ||
## ConnectionIsValid | ||
<small>*Namespace: SynicSugar.P2P* <br> | ||
*Class: p2pInfo* </small> | ||
|
||
public bool ConnectionIsValid () | ||
|
||
|
||
### Description | ||
Checks if the connection has been enabled by the library or user.<br> | ||
This does not necessarily mean that an actual connection has been established.<br> | ||
The IsConnected flag becomes true after the user or library initiates the connection.<br> | ||
After that, it will never become False unless we explicitly Pause connection.<br> | ||
|
||
```cs | ||
using SynicSugar.P2P; | ||
using UnityEngine; | ||
[NetworkCommons] | ||
public partial class p2pSample : MonoBehaviour { | ||
|
||
public void RestartConnection(){ | ||
if(p2pInfo.Instance.ConnectionIsValid()){ | ||
return; | ||
} | ||
ConnectHub.Instance.RestartConnections(); | ||
} | ||
} | ||
``` |
41 changes: 41 additions & 0 deletions
41
docs/content/SynicSugar.P2P/p2pInfo/CurrentSessionStartUTC.md
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,41 @@ | ||
+++ | ||
title = "CurrentSessionStartUTC" | ||
weight = 2 | ||
+++ | ||
## CurrentSessionStartUTC | ||
<small>*Namespace: SynicSugar.P2P* <br> | ||
*Class: p2pInfo* </small> | ||
|
||
public DateTime CurrentSessionStartUTC { get; internal set; } | ||
|
||
|
||
### Description | ||
Date time when this LOCAL user starts current session.<br><br> | ||
|
||
This time is the UTC just before the matchmaking results are returned. When matchmaking is decided and all preparations are complete, the LobbyID and UTC are saved in Application.persistentDataPath/ss_sessiondata.dat. The in-game timestamp is calculated based on the difference between this reference time and the current UTC.<br> | ||
In P2P, there is no server, so server time cannot be used for the game. Additionally, Ping and RTC can be unreliable due to processing congestion, so SynicSugar saves the time when matchmaking finished on each device and uses it as a reference time.<br> | ||
When reconnecting, if this value exists locally, it is used again. If it doesn't exist, an estimated start time is calculated from the elapsed time timestamp sent by the host and set to this value.<br><br> | ||
|
||
|
||
```cs | ||
using SynicSugar.P2P; | ||
using UnityEngine; | ||
[NetworkPlayer] | ||
public partial class p2pSample : MonoBehaviour { | ||
void Start(){ | ||
//For standard | ||
Move(p2pInfo.Instance.GetSessionTimestamp()); | ||
|
||
//To need rigorous time | ||
Fire(p2pInfo.Instance.GetSessionTimestampInMs()); | ||
} | ||
[Rpc] | ||
void Move(uint timestamp){ | ||
Debug.Log($"Lag is {p2pInfo.Instance.GetSessionTimestamp() - timestamp} sec"); | ||
} | ||
[Rpc] | ||
void Fire(double timestamp){ | ||
Debug.Log($"Lag is {p2pInfo.Instance.GetSessionTimestampInMs() - timestamp} ms"); | ||
} | ||
} | ||
``` |
34 changes: 34 additions & 0 deletions
34
docs/content/SynicSugar.P2P/p2pInfo/GetActiveReceiverType.md
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,34 @@ | ||
+++ | ||
title = "GetActiveReceiverType" | ||
weight = 6 | ||
+++ | ||
## GetActiveReceiverType | ||
<small>*Namespace: SynicSugar.P2P* <br> | ||
*Class: p2pInfo* </small> | ||
|
||
public ReceiverType GetActiveReceiverType ()<br> | ||
|
||
```cs | ||
public enum ReceiverType { | ||
None, FixedUpdate, Update, LateUpdate, Synic | ||
} | ||
``` | ||
|
||
### Description | ||
Gets the currently valid (active) packet receiver type.<br> | ||
|
||
|
||
```cs | ||
using SynicSugar.P2P; | ||
using UnityEngine; | ||
[NetworkCommons] | ||
public partial class p2pSample : MonoBehaviour { | ||
|
||
public void Start(){ | ||
if(ReceiverType.None == p2pInfo.Instance.GetActiveReceiverType()){ | ||
ConnectHub.Instance.StartPacketReceiver(PacketReceiveTiming.FixedUpdate, 5); | ||
//p2pInfo.Instance.GetActiveReceiverType() becomes ReceiverType.FixedUpdate | ||
} | ||
} | ||
} | ||
``` |