Exemplo n.º 1
0
func main() {
	cine.Init("127.0.0.1:9000")
	phonebook := Phonebook{cine.Actor{}, make(map[string]int)}
	pid := cine.StartActor(&phonebook)
	fmt.Println("pid:", pid)
	cine.Call(pid, (*Phonebook).Add, "Jane", 1234)
	r, _ := cine.Call(pid, (*Phonebook).Lookup, "Jane")
	fmt.Printf("Lookup('Jane') == %v\n", r[0].(int))
}
Exemplo n.º 2
0
func main() {
	cine.Init("127.0.0.1:8000")
	phonebook := Phonebook{cine.Actor{}, make(map[string]int)}
	pid := cine.StartActor(&phonebook)

	cine.Cast(pid, nil, (*Phonebook).Add, "Jane", 1234)
	ret, _ := cine.Call(pid, (*Phonebook).Lookup, "Jane")
	number := ret[0].(int)
	log.Infoln("number:", number)
	// Out: number: 1234
}
Exemplo n.º 3
0
func main() {
	playerNum := os.Args[1]
	if playerNum == "1" {
		cine.Init("127.0.0.1:3000")
	} else {
		cine.Init("127.0.0.1:3001")
	}
	player := Player{cine.Actor{}, 0}
	waitGroup.Add(1)
	pid := cine.StartActor(&player)
	glog.Infoln("pid:", pid)
	if playerNum == "2" {
		to := cine.Pid{"127.0.0.1:3000", 1}
		myPlayer := PlayerProxy{Pid: pid}
		myPlayer.Start(to)
	}
	waitGroup.Wait()
}