Esempio n. 1
0
        protected override void Start()
        {
            _clientOption.IsServiceUdp          = true;
            _clientOption.UdpServerAddress      = ServerAddress;
            _clientOption.UdpServerPort         = UdpServerPort;
            _clientOption.PingInterval          = PingInterval;
            _clientOption.MtuInterval           = MtuInterval;
            _clientOption.RudpDisconnectTimeout = RudpDisconnectTimeout;
            _clientOption.TcpServerAddress      = ServerAddress;
            _clientOption.TcpServerPort         = TcpServerPort;
            _clientOption.IsCheckAlive          = IsCheckAlive;
            _clientOption.CheckAliveInterval    = CheckAliveInterval;
            _clientOption.CheckAliveTimeout     = CheckAliveTimeout;

            SetClientOption(_clientOption);

            _client = new NetClientP2p(
                _clientOption,
                DefaultLoggerFactory.Create(builder =>
            {
                builder.SetMinimumLevel(LogLevel);
                builder.AddUnityDebugLogger();
            }));

            ClientP2p.SyncType     = SyncType;
            ClientP2p.SyncInterval = SyncInterval;

            _client.OnErrored += OnError;

            NetClientGlobal.Instance.SetClient(ClientP2p);
        }
Esempio n. 2
0
        /// <summary>
        /// P2P 클라이언트를 등록함. NetClientP2pBehaviour를 사용하면 자동으로 등록됨
        /// </summary>
        /// <param name="client">등록할 NetClientP2p</param>
        public void SetClient(NetClientP2p client)
        {
            if (client != null && _client != null)
            {
                Debug.LogError("[NetClientP2p] should have only one instance.");
            }

            _client = client;
        }