Ejemplo n.º 1
0
// HandleCall handles incoming messages from `gen_server:call/2`, if returns non-nil term,
// then calling process have reply
// Call `gen_server:call({go_srv, gonode@localhost}, Message)` at Erlang node
func (gs *gonodeSrv) HandleCall(message *erl.Term, from *erl.Tuple) (reply *erl.Term) {
	log.Printf("GO_SRV: HandleCall: %#v, From: %#v", *message, *from)

	// Just create new term tuple where first element is atom 'ok', second 'go_reply' and third is original message
	replyTerm := erl.Term(erl.Tuple{erl.Atom("ok"), erl.Atom("go_reply"), *message})
	reply = &replyTerm
	return
}
Ejemplo n.º 2
0
func (rpcs *rpcRex) HandleCall(message *erl.Term, from *erl.Tuple) (reply *erl.Term) {
	nLog("REX: HandleCall: %#v, From: %#v", *message, *from)
	switch req := (*message).(type) {
	case erl.Tuple:
		if len(req) > 0 {
			switch act := req[0].(type) {
			case erl.Atom:
				if string(act) == "call" {
					nLog("RPC CALL: Module: %#v, Function: %#v, Args: %#v, GroupLeader: %#v", req[1], req[2], req[3], req[4])
					replyTerm := erl.Term(erl.Tuple{req[1], req[2]})
					reply = &replyTerm
				}
			}
		}
	}
	if reply == nil {
		replyTerm := erl.Term(erl.Tuple{erl.Atom("badrpc"), erl.Atom("unknown")})
		reply = &replyTerm
	}
	return
}
Ejemplo n.º 3
0
func (nk *netKernel) HandleCall(message *erl.Term, from *erl.Tuple) (reply *erl.Term) {
	nLog("NET_KERNEL: HandleCall: %#v, From: %#v", *message, *from)
	switch t := (*message).(type) {
	case erl.Tuple:
		if len(t) == 2 {
			switch tag := t[0].(type) {
			case erl.Atom:
				if string(tag) == "is_auth" {
					nLog("NET_KERNEL: is_auth: %#v", t[1])
					replyTerm := erl.Term(erl.Atom("yes"))
					reply = &replyTerm
				}
			}
		}
	}
	return
}
Ejemplo n.º 4
0
func (gns *globalNameServer) HandleCall(message *erl.Term, from *erl.Tuple) (reply *erl.Term) {
	nLog("GLOBAL_NAME_SERVER: HandleCall: %#v, From: %#v", *message, *from)
	replyTerm := erl.Term(erl.Atom("reply"))
	reply = &replyTerm
	return
}