Ejemplo n.º 1
0
func (e *Export) deliverResult(d eventual2go.Data) {
	result := d.(*messages.Result)
	e.logger.Println("Delivering result", result.Request.Function, result.Request.CallType)
	switch result.Request.CallType {
	case messages.ONE2MANY, messages.ONE2ONE:
		if sc := e.GetConnectedService(result.Request.Importer); sc != nil {
			sc.Send(messages.Flatten(result))
		}

<<<<<<< HEAD
	case messages.MANY2MANY, messages.MANY2ONE:
		res := messages.Flatten(result)
		e.logger.Printf("sending many2 result to %d clients", len(e.listeners))
		for _, uuid := range e.listeners[result.Request.Function] {
			e.logger.Println("Sending result", uuid, result.Request.Function)
			e.GetConnectedService(uuid).Send(res)
		}
	}
=======
	for _, iface := range config.NetworkInterfaces {
		exp.nodes = append(exp.nodes, network.NewNode(iface, config.Logger()))
	}

	return exp
>>>>>>> 9662249fbabc683e2a4371d4ec5052b3d5b687a3
}
Ejemplo n.º 2
0
func (i *Import) StopListen(function string) {
	index := -1
	for i, f := range i.listen {
		if f == function {
			index = i
			break
		}
	}
	if index == -1 {
		return
	}
	switch len(i.listen) {

	case 1:
		i.listen = []string{}
	case 2:
		if index == 0 {
			i.listen = []string{i.listen[1]}
		} else {
			i.listen = []string{i.listen[0]}
		}
	default:
		i.listen[index] = i.listen[len(i.listen)-1]
		i.listen = i.listen[:len(i.listen)-2]

	}
	for _, sc := range i.GetConnectedServices() {
		sc.Send(messages.Flatten(&messages.StopListen{function}))
	}
}
Ejemplo n.º 3
0
func (i *Import) sendListenFunctions(d eventual2go.Data) {
	sc := d.(*service.ServiceConnection)
	for _, f := range i.listen {
		sc.Send(messages.Flatten(&messages.Listen{f}))
	}
	return
}
Ejemplo n.º 4
0
func (sc *ServiceConnection) DoHandshakeReply(codecs []byte) {
	if sc.handshaked {
		return
	}
	m := &messages.HelloOk{codecs}
	sc.Send(messages.Flatten(m))
	sc.handshaked = true
}
Ejemplo n.º 5
0
func (e *Export) deliverResult(d eventual2go.Data) {
	result := d.(*messages.Result)
	e.logger.Println("Delivering result", result.Request.Function, result.Request.CallType)
	switch result.Request.CallType {
	case messages.ONE2MANY, messages.ONE2ONE:
		if sc := e.GetConnectedService(result.Request.Importer); sc != nil {
			sc.Send(messages.Flatten(result))
		}

	case messages.MANY2MANY, messages.MANY2ONE:
		res := messages.Flatten(result)
		e.logger.Printf("sending many2 result to %d clients", len(e.listeners))
		for _, uuid := range e.listeners[result.Request.Function] {
			e.logger.Println("Sending result", uuid, result.Request.Function)
			e.GetConnectedService(uuid).Send(res)
		}
	}
}
Ejemplo n.º 6
0
func (i *Import) deliverRequest(r *messages.Request) {
	for _, sc := range i.GetConnectedServices() {
		i.logger.Println("Delivering Request to", sc.Uuid())
		sc.Send(messages.Flatten(r))
		if r.CallType == messages.ONE2ONE || r.CallType == messages.MANY2ONE {
			return
		}
	}
	return
}
Ejemplo n.º 7
0
func (i *Import) Listen(function string) {
	for _, f := range i.listen {
		if f == function {
			return
		}
	}
	i.listen = append(i.listen, function)
	for _, sc := range i.GetConnectedServices() {
		sc.Send(messages.Flatten(&messages.Listen{function}))
	}
}
Ejemplo n.º 8
0
func (i *Import) StopListen(function string) {
	index := -1
	for i, f := range i.listen {
		if f == function {
			index = i
			break
		}
	}
	if index == -1 {
		return
	}
	i.listen[index] = i.listen[len(i.listen)-1]
	i.listen = i.listen[:len(i.listen)-2]
	for _, sc := range i.GetConnectedServices() {
		sc.Send(messages.Flatten(&messages.StopListen{function}))
	}
}
Ejemplo n.º 9
0
func (sc *ServiceConnection) DoHandshake(codecs []byte, address string, port int) {
	m := &messages.Hello{codecs, address, port}
	sc.Send(messages.Flatten(m))
}