コード例 #1
0
        public NatPunchId Punch(IPEndPoint remoteEndpoint, OnNatPunchSuccess onSuccess = null, OnNatPunchFailure onFailure = null)
        {
            onSuccess = onSuccess ?? EmptyOnSuccess;
            onFailure = onFailure ?? EmptyOnFailure;

            var attempt = new PunchAttempt();

            attempt.Timestamp = DateTime.Now;
            attempt.EndPoint  = remoteEndpoint;
            // TODO Recycle tokens
            attempt.PunchId    = new NatPunchId(Guid.NewGuid().ToString());
            attempt.OnSuccess += onSuccess;
            attempt.OnFailure += onFailure;
            AddNatPunchAttempt(attempt);

            _facilitatorConnection.SendIntroduction(remoteEndpoint, attempt.PunchId);

            return(attempt.PunchId);
        }
コード例 #2
0
 private void RemoveNatPunchAttempt(PunchAttempt attempt)
 {
     _natPunchAttempts.Remove(attempt.PunchId);
     _natPunchRegistrations.Remove(attempt);
 }
コード例 #3
0
 private void AddNatPunchAttempt(PunchAttempt attempt)
 {
     _natPunchAttempts[attempt.PunchId] = attempt;
     _natPunchRegistrations.Add(attempt);
 }