Ejemplo n.º 1
0
func (c *Client) onHello(d eventual2go.Data) {
	m := d.(connection.Message)
	strport := string(m.Payload[3])
	port, _ := strconv.ParseInt(strport, 0, 0)
	c.logger.Println("got hello from daemon on port", port)
	c.daemonPort = int(port)
	c.daemonConn, _ = connection.NewOutgoing(c.uuid, c.daemonAddr, c.daemonPort)
	h := NewService{c.uuid, c.ad, c.addresses, c.ports, c.servicetype}
	c.daemonConn.Add(h.flatten())
}
Ejemplo n.º 2
0
func (sc *ServiceConnection) Connect(name, address string, port int) {
	var err error
	if _, f := sc.connections[address]; !f {
		sc.connections[address], err = connection.NewOutgoing(name, address, port)
		if err != nil {
			delete(sc.connections, address)
		} else if !sc.connected.Completed() {
			sc.connected.Complete(sc)
		}
	}
}
Ejemplo n.º 3
0
func (d *Daemon) newClient(port int) eventual2go.Subscriber {
	return func(data eventual2go.Data) {
		np := data.(Newclient)
		d.logger.Println("new client", np)
		conn, err := connection.NewOutgoing("AURARATH_DAEMON", "127.0.0.1", np.Port)
		if err != nil {
			d.logger.Println("error opening connection:", err)
			return
		}
		conn.Add(NewHello(port))
		d.clients[np.UUID] = conn

	}
}