Skip to content
This repository was archived by the owner on May 27, 2021. It is now read-only.

Commit 0d4e293

Browse files
committed
agent: add WithTa and WithMaxAttempts options
1 parent f8e148c commit 0d4e293

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

agent_option.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package ice
22

33
import (
4+
"errors"
45
"strings"
6+
"time"
57

68
"go.uber.org/zap"
79

@@ -99,3 +101,22 @@ var WithIPv4Only AgentOption = func(a *Agent) error {
99101
a.ipv4Only = true
100102
return nil
101103
}
104+
105+
// WithTa sets Ta timer value which is technically time between candidates.
106+
func WithTa(ta time.Duration) AgentOption {
107+
return func(a *Agent) error {
108+
if ta < 0 {
109+
return errors.New("ta should be positive")
110+
}
111+
a.ta = ta
112+
return nil
113+
}
114+
}
115+
116+
// WithMaxAttempts sets maximum attempts.
117+
func WithMaxAttempts(n int) AgentOption {
118+
return func(a *Agent) error {
119+
a.maxAttempts = n
120+
return nil
121+
}
122+
}

0 commit comments

Comments
 (0)