func (self *comm) await_cmd_ack(cmd link.Command) (bool, link.Arguments) { msg := self.recv() proc := func(ack bool) (bool, link.Arguments) { acked := link.MakeCommand(msg.Args[0]) if acked == cmd { if ack == true { return ack, msg.Args } else { return ack, nil } } else { var s string if ack { s = fmt.Sprintf("Acked incorrect cmd (expected %s) %s", cmd, msg) } else { s = fmt.Sprintf("Ncked incorrect cmd (expected %s) %s", cmd, msg) } panic(s) } panic("unreachable") } if msg.Cmd == link.Commands["Ack"] && len(msg.Args) >= 1 { return proc(true) } else if msg.Cmd == link.Commands["Nak"] && len(msg.Args) == 1 { return proc(false) } s := fmt.Sprintf("Unexpected Message %s", msg) panic(s) }
func (self *AgentProxy) await_cmd_ack(cmd link.Command) bool { if ok, msg := self.recv(); ok { if msg.Cmd == link.Commands["Ack"] && len(msg.Args) == 1 { if acked := link.MakeCommand(msg.Args[0]); acked == cmd { return true } } } return false }