42 lines
617 B
Go
42 lines
617 B
Go
package cmppadapter
|
|
|
|
import (
|
|
"time"
|
|
|
|
cmpp "github.com/bigwhite/gocmpp"
|
|
)
|
|
|
|
type Version string
|
|
|
|
const (
|
|
Version20 Version = "2.0"
|
|
Version30 Version = "3.0"
|
|
)
|
|
|
|
type ClientConfig struct {
|
|
Version Version
|
|
Address string
|
|
User string
|
|
Password string
|
|
Timeout time.Duration
|
|
}
|
|
|
|
type Client struct {
|
|
raw *cmpp.Client
|
|
}
|
|
|
|
func NewClient(config ClientConfig) *Client {
|
|
return &Client{raw: cmpp.NewClient(toProtocolType(config.Version))}
|
|
}
|
|
|
|
func (c *Client) Raw() *cmpp.Client {
|
|
return c.raw
|
|
}
|
|
|
|
func toProtocolType(version Version) cmpp.Type {
|
|
if version == Version20 {
|
|
return cmpp.V20
|
|
}
|
|
return cmpp.V30
|
|
}
|