ConnectHub 

    Namespace: SynicSugar.P2P

    Description 

    Manage around p2p connections.
    This script is Singleton generated by SourceGenerator. This behaves like a network server, and SynicSugar send and receive packets through this ConnectHub.

    At compile, SourceGenerator generates a ConnectHub for each assembly with variables and functions according for the Network attribute. In other words, each assembly has different ConnectHub and that instance. Usually an instance calls ConnectHub in the same assembly automatically. There is no need for us to do anything special for this.

    Each assembly can have max 250 variables and functions with Network attribute (share the limit with SyncVar, RPC and TargetRPC).

    Properity 

    APIdescription
    InstanceThis scrip's instance
    ChannelsList of all variable and functions having Network attribute

    Function 

    APIdescription
    StartSynicReceiverStart the synic receiver to get only synic packet from buffer
    StartPacketReceiver(Re)Start the packet receiver to get packet from buffer
    StopPacketReceiverStop to get a packet from the buffer
    PauseConnectionsPause receiving a packet to the receive buffer
    RestartConnectionsRestart to receive packets receive buffer
    ExitSessionLeave connection
    CloseSessionClose connection. (If Host, close the Lobby)
    DestoryOfflineLobbyDestory offline-lobby and stop offline mode
    RegisterInstanceRegister instance to receive packets
    GetUserInstanceGet a NetworkPlayer instance of target user registered to ConnectHub
    GetInstanceGet a NetworkCommons instance registered to ConenctHub
    SyncSynicSynchronize all own Synic variables at once to TargetUser
    ResendLastRPCRe-Send RPC with last recorded information
    ResendLastRPCToTargetRe-Send RPC to the specific target with last recorded information
    ResendLastTargetRPCRe-Send TargetRPC with last recorded information.
    using SynicSugar.P2P;
    
    public class p2pSample {
        public void StartConnection(){
            ConnectHub.Instance.StartPacketReceiver();
        }
    }