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); }
private void RemoveNatPunchAttempt(PunchAttempt attempt) { _natPunchAttempts.Remove(attempt.PunchId); _natPunchRegistrations.Remove(attempt); }
private void AddNatPunchAttempt(PunchAttempt attempt) { _natPunchAttempts[attempt.PunchId] = attempt; _natPunchRegistrations.Add(attempt); }