コード例 #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
ファイル: grunner.go プロジェクト: papmech/Distributed-2048
func main() {
	flag.Parse()
	gs, err := gameserver.NewGameServer(*centralHostPort, *hostname, *port, "/abc")
	if err != nil {
		fmt.Println("Could not create game server.")
		fmt.Println(err)
		os.Exit(1)
	}
	if *isFaulty {
		gs.GetLibpaxos().SetInterruptFunc(interrupt)
	}

	fmt.Printf("Game Server running on %s:%d\n", *hostname, *port)

	// Run the game server forever
	select {}
}