Ejemplo n.º 1
0
// NewClient creates a new instance of client.
func NewClient(address string) *Client {
	client := Client{}
	client.sub.AppendAddress(entity.Address(address))

	env, err := entity.CreateZMQCommEnv(true)
	if err != nil {
		return nil
	}
	if client.sub.InitialConnecting(env) != nil {
		return nil
	}
	return &client
}
Ejemplo n.º 2
0
// NewServer creates a new Server instance.
func NewServer(address []string) *Server {
	server := Server{Interval: 1,
		data:      make(chan *model.TimeStruct),
		Generator: newTimeFormatData,
	}
	for _, val := range address {
		server.pub.AppendAddress(entity.Address(val))
	}
	env, err := entity.CreateZMQCommEnv(true)
	if err != nil {
		return nil
	}
	if server.pub.InitialBinding(env) != nil {
		return nil
	}
	return &server
}