2016-02-12 04:03:42 +00:00
|
|
|
package libnmdc
|
|
|
|
|
|
|
|
import (
|
2016-04-03 01:15:57 +00:00
|
|
|
"errors"
|
2017-11-22 06:05:36 +00:00
|
|
|
"strconv"
|
2016-02-12 04:03:42 +00:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2016-04-03 06:53:14 +00:00
|
|
|
const (
|
2017-11-14 05:45:06 +00:00
|
|
|
DEFAULT_CLIENT_TAG string = "libnmdc.go"
|
2017-11-26 06:36:20 +00:00
|
|
|
DEFAULT_CLIENT_VERSION string = "0.17"
|
2017-11-14 05:45:06 +00:00
|
|
|
DEFAULT_HUB_NAME string = "(unknown)"
|
|
|
|
SEND_KEEPALIVE_EVERY time.Duration = 29 * time.Second
|
|
|
|
AUTO_RECONNECT_AFTER time.Duration = 30 * time.Second
|
|
|
|
RECONNECT_IF_NO_DATA_RECIEVED_IN time.Duration = 24 * time.Hour // we expect keepalives wayyyy more frequently than this
|
2017-11-22 06:22:13 +00:00
|
|
|
AUTODETECT_ADC_NMDC_TIMEOUT time.Duration = 3 * time.Second
|
2016-04-03 06:53:14 +00:00
|
|
|
)
|
|
|
|
|
2016-04-03 01:15:57 +00:00
|
|
|
var ErrNotConnected error = errors.New("Not connected")
|
2016-02-12 04:03:42 +00:00
|
|
|
|
2017-11-22 06:05:36 +00:00
|
|
|
func maybeParse(str string, dest *uint64, default_val uint64) {
|
|
|
|
sz, err := strconv.ParseUint(str, 10, 64)
|
|
|
|
if err == nil {
|
|
|
|
*dest = sz
|
|
|
|
} else {
|
|
|
|
*dest = default_val
|
2016-02-12 04:03:42 +00:00
|
|
|
}
|
|
|
|
}
|