2015-09-05 11:48:38 -04:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
2015-09-06 16:10:42 -04:00
|
|
|
"fmt"
|
2015-09-05 11:48:38 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type VPoint struct {
|
2015-09-06 16:10:42 -04:00
|
|
|
config VConfig
|
|
|
|
connHandler ConnectionHandler
|
2015-09-05 11:48:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewVPoint(config *VConfig) (*VPoint, error) {
|
2015-09-06 16:10:42 -04:00
|
|
|
var vpoint *VPoint
|
|
|
|
return vpoint, nil
|
2015-09-05 11:48:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
type ConnectionHandler interface {
|
2015-09-06 16:10:42 -04:00
|
|
|
Listen(port uint16) error
|
2015-09-05 11:48:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (vp *VPoint) Start() error {
|
2015-09-06 16:10:42 -04:00
|
|
|
if vp.config.Port <= 0 {
|
|
|
|
return fmt.Errorf("Invalid port %d", vp.config.Port)
|
|
|
|
}
|
|
|
|
vp.connHandler.Listen(vp.config.Port)
|
|
|
|
return nil
|
|
|
|
}
|