libnmdc/libnmdc.go

36 lines
852 B
Go
Raw Normal View History

2016-02-12 04:03:42 +00:00
package libnmdc
import (
"errors"
"strconv"
2016-02-12 04:03:42 +00:00
"time"
)
2016-04-03 06:53:14 +00:00
const (
DEFAULT_CLIENT_TAG string = "libnmdc.go"
2017-11-14 05:45:36 +00:00
DEFAULT_CLIENT_VERSION string = "0.15"
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
2016-04-03 06:53:14 +00:00
)
var ErrNotConnected error = errors.New("Not connected")
2016-02-12 04:03:42 +00:00
type HubProtocol int
const (
HubProtocolAutodetect = 0
HubProtocolNmdc = 1
HubProtocolAdc = 2
)
2016-02-12 04:03:42 +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
}
}