StartSynicReceiver
Namespace: SynicSugar.P2P
Class: ConnectHub
public void StartSynicReceiver(byte maxBatchSize = 1)
Description
Start Packet Receiver to get only Synic packets (in Unity.Update) from the receiving buffer.
This cannot be called with other Receiver at the same time. If start the other Receiver, ConenctHub stop this Receiver automatically before start the new one.
Need the Instance of each Class to get the packet.
So, genarete the components by SynicObject, or set UserID in or after Unity.Start to Register the instanced to ConnectHub.
NetworkComponents need call RegisterInstance in or after Unity.Start by hand.
using SynicSugar.P2P;
using Cysharp.Threading.Tasks;
public class p2pSample {
async void UniTaskVoid Start(){
//This user is Reconnecter
if(p2pInfo.Instance.IsReconnecter){
//To get SynicPacket.
ConnectHub.Instance.StartSynicReceiver(8);
//This flag(HasReceivedAllSyncSynic) cannot be used at the same time. Once it returns True, it returns False again.
await UniTask.WaitUntil(() => p2pInfo.Instance.HasReceivedAllSyncSynic);
}
}
ConnectHub.Instance.StartPacketReceiver(maxBatchSize: 5);
}
}