public NatPunchId Punch(IPEndPoint remoteEndpoint, OnNatPunchSuccess onSuccess = null, OnNatPunchFailure onFailure = null) { onSuccess = onSuccess ?? EmptyOnSuccess; onFailure = onFailure ?? EmptyOnFailure; var attempt = _punchAttemptPool.Take(); attempt.Instance.Timestamp = DateTime.Now; attempt.Instance.EndPoint = remoteEndpoint; _natPunchIds.MoveNext(); attempt.Instance.PunchId = _natPunchIds.Current; attempt.Instance.OnSuccess += onSuccess; attempt.Instance.OnFailure += onFailure; AddNatPunchAttempt(attempt); _facilitatorConnection.SendIntroduction(remoteEndpoint, attempt.Instance.PunchId); return(attempt.Instance.PunchId); }
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); }