|
@@ -9,8 +9,11 @@ type VPoint struct {
|
|
|
connHandler ConnectionHandler
|
|
connHandler ConnectionHandler
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// NewVPoint returns a new VPoint server based on given configuration.
|
|
|
|
|
+// The server is not started at this point.
|
|
|
func NewVPoint(config *VConfig) (*VPoint, error) {
|
|
func NewVPoint(config *VConfig) (*VPoint, error) {
|
|
|
- var vpoint *VPoint
|
|
|
|
|
|
|
+ var vpoint = new(VPoint)
|
|
|
|
|
+ vpoint.config = *config
|
|
|
return vpoint, nil
|
|
return vpoint, nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -18,6 +21,8 @@ type ConnectionHandler interface {
|
|
|
Listen(port uint16) error
|
|
Listen(port uint16) error
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// Start starts the VPoint server, and return any error during the process.
|
|
|
|
|
+// In the case of any errors, the state of the server is unpredicatable.
|
|
|
func (vp *VPoint) Start() error {
|
|
func (vp *VPoint) Start() error {
|
|
|
if vp.config.Port <= 0 {
|
|
if vp.config.Port <= 0 {
|
|
|
return fmt.Errorf("Invalid port %d", vp.config.Port)
|
|
return fmt.Errorf("Invalid port %d", vp.config.Port)
|