p2pInfo 

    Namespace: SynicSugar.P2P

    This is used like p2pinfo.Instance.XXX().

    Description 

    This manages data after p2p connections have established.

    This script is Mono's Singleton attached to NetworkManager. To generate NetworkManager, right-click on the Hierarchy and click SynicSugar/NetworkManager
    NetworkManager has DontDestroy, so NetworkManager will not be destroyed by scene transitions.

    If this is no longer needed, we call CancelCurrentMatchMake, ConnectHub.Instance.CloseSession(CancellationTokenSource) or ConnectHub.Instance.ExitSession(CancellationTokenSource).

    Properity 

    APIdescription
    HostUserIdHost's UserId in this lobby
    LocalUserIdUserID of this local
    CurrentRemoteUserIdsUserIDs of current conenction
    DisconnectedUserIdsDisconnected user ids. (May come back, not exit)
    CurrentConnectedUserIdsConnected user ids include Local UserId
    CurrentAllUserIdsAllUserIds - LeftUsers (not disconnected)
    AllUserIdsAllUserIds in the session
    AcceptHostSynicIf true, host overwrite this local user instnace
    ConnectionNotifierNotifers when a user connects or disconnects
    LastDisconnectedUsersReasonThe reason of last disconnected user
    LastDisconnectedUsersIdUserID of last Disconnected user
    LastConnectedUsersIdUserID of last Connected user
    SyncSnyicNotifierNotifers when a user get SynicVariables
    HasReceivedAllSyncSynicReturn True only once after local user receives all SyncSynics
    SyncedSynicPhaseThe SyncSynic phase of last received
    LastSyncedUserIdThe UserID of last synced SyncSynic
    LastRPCPayloadThe last byte array sent with RPC that record data
    LastRPCchThe last ch sent with RPC that record data
    LastTargetRPCPayloadThe last byte array sent with TargetRPC that record data
    LastTargetRPCchThe last ch sent with TargetRPC that record data
    LastTargetRPCUserIdThe last UserId sent with TargetRPC that record data
    IsReconnecterReturn true until reconencter gets self Synic data.

    Function 

    APIdescription
    IsLoaclUserIf target is LocalUser, return true
    IsHostIf local or target user is host, return true
    GetUserIndexGet the user unique index in AllUserIds
    QueryNATTypeUpdate local user's NATType to the latest
    GetNATTypeGet last-queried NAT-type
    GetPingGet a ping with a peer from cache
    RefreshPingRefresh ping with other all peers
    using SynicSugar.P2P;
    using UnityEngine;
    [NetworkPlayer]
    public class p2pSample : MonoBehaviour {
        void Start(){
            if(!isLoacl){
                return;
            }
            
            p2pInfo.Instance.ConnectionNotifier.Disconnected += OnDisconect;
    
            if(p2pInfo.Instance.IsHost()){
                p2pInfo.Instance.ConnectionNotifier.Connected += () => Debug.Log($"{p2pConfig.Instance.LastConnectedUsersId} Join");
            }
        }
    
        void OnDisconect(){
            Debug.Log($"{p2pInfo.Instance.LastDisconnectedUsersId} is Disconnected / {p2pInfo.Instance.ClosedReason}");
        }
    }