public LidgrenPunchThroughFacilitator(LidgrenNetworkTransporter transporter,
                                              ICoroutineScheduler coroutineScheduler, LidgrenNatPunchClient natPunchClient, float connectionAttemptTimeout,
                                              ConnectionIdPool connectionIdPool)
        {
            _connectionIdPool           = connectionIdPool;
            _connectionRegistrationPool = new ObjectPool <ConnectionRegistration>(() => new ConnectionRegistration());

            _punchAttempts      = new Dictionary <NatPunchId, IPooledObject <ConnectionRegistration> >();
            _connectionAttempts = new ArrayDictionary <ConnectionId, IPooledObject <ConnectionRegistration> >(
                connectionIdPool.MaxConnectionIds);
            _activeConnections = new ArrayDictionary <ConnectionId, IPooledObject <ConnectionRegistration> >(
                connectionIdPool.MaxConnectionIds);

            _cancelledAttempts = new ConnectionId[_connectionIdPool.MaxConnectionIds];
            for (int i = 0; i < _cancelledAttempts.Length; i++)
            {
                _cancelledAttempts[i] = ConnectionId.NoConnection;
            }

            _transporter = transporter;
            _connectionAttemptTimeout = connectionAttemptTimeout;
            _connectionIdPool         = connectionIdPool;
            _natPunchClient           = natPunchClient;

            _transporter.RequestApproval    += PassRequestApproval;
            _transporter.OnConnectionOpened += OnConnectionOpened;
            _transporter.OnConnectionClosed += OnConnectionClosed;

            _cleanupRoutine = coroutineScheduler.Run(PunchTimeoutCleanup());
        }
        public LidgrenPunchThroughFacilitator(LidgrenNetworkTransporter transporter,
                                              ICoroutineScheduler coroutineScheduler, LidgrenNatPunchClient natPunchClient, float connectionAttemptTimeout)
        {
            _punchAttempts                  = new Dictionary <NatPunchId, ConnectionRegistration>();
            _connectionAttempts             = new Dictionary <ConnectionId, ConnectionRegistration>();
            _connectionAttemptRegistrations = new List <ConnectionRegistration>();
            _connections = new Dictionary <ConnectionId, ConnectionRegistration>();

            _transporter = transporter;
            _connectionAttemptTimeout = connectionAttemptTimeout;
            _natPunchClient           = natPunchClient;

            _transporter.OnConnectionOpened += OnConnectionOpened;
            _transporter.OnConnectionClosed += OnConnectionClosed;

            _cleanupRoutine = coroutineScheduler.Run(ConnectionTimeoutCleanup());
        }