示例#1
0
func main() {
	_, err := centralserver.NewCentralServer(15340, 3)
	if err != nil {
		LOGV.Println("Could not start central server.")
		LOGV.Println(err)
		os.Exit(1)
	}
	time.Sleep(1 * time.Second)

	gameServers := make([]gameserver.GameServer, 0)
	gsCh := make(chan gameserver.GameServer)
	makeGS := func(ch chan gameserver.GameServer, master, hostname string, port int, pattern string) {
		gs, _ := gameserver.NewGameServer(master, hostname, port, pattern)
		ch <- gs
	}

	for i := 0; i < 3; i++ {
		go makeGS(gsCh, "localhost:15340", "localhost", 15400+i, "/")
	}
	for i := 0; i < 3; i++ {
		gs := <-gsCh
		gameServers = append(gameServers, gs)
	}

	moves := []paxosrpc.Move{
		*paxosrpc.NewMove(paxosrpc.Up),
		*paxosrpc.NewMove(paxosrpc.Up),
		*paxosrpc.NewMove(paxosrpc.Down),
		*paxosrpc.NewMove(paxosrpc.Left),
	}
	gameServers[0].TestAddVote(moves)

	os.Exit(0)
}
示例#2
0
func main() {
	flag.Parse()
	_, err := centralserver.NewCentralServer(*port, *numGameServers)
	if err != nil {
		fmt.Println("Could not create central server.")
		fmt.Println(err)
		os.Exit(1)
	}

	fmt.Println("Central Server running on port", *port)

	// Run the central server forever
	select {}
}