forked from schwartzmx/gremgo-neptune
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.go
42 lines (35 loc) · 1.14 KB
/
configuration.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package gremgo
import "time"
//DialerConfig is the struct for defining configuration for WebSocket dialer
type DialerConfig func(*Ws)
//SetAuthentication sets on dialer credentials for authentication
func SetAuthentication(username string, password string) DialerConfig {
return func(c *Ws) {
c.auth = &auth{username: username, password: password}
}
}
//SetTimeout sets the dial timeout
func SetTimeout(seconds int) DialerConfig {
return func(c *Ws) {
c.timeout = time.Duration(seconds) * time.Second
}
}
//SetPingInterval sets the interval of ping sending for know is
//connection is alive and in consequence the client is connected
func SetPingInterval(seconds int) DialerConfig {
return func(c *Ws) {
c.pingInterval = time.Duration(seconds) * time.Second
}
}
//SetWritingWait sets the time for waiting that writing occur
func SetWritingWait(seconds int) DialerConfig {
return func(c *Ws) {
c.writingWait = time.Duration(seconds) * time.Second
}
}
//SetReadingWait sets the time for waiting that reading occur
func SetReadingWait(seconds int) DialerConfig {
return func(c *Ws) {
c.readingWait = time.Duration(seconds) * time.Second
}
}