func main() { log.SetFlags(log.LstdFlags | log.Lshortfile) log.Println("Version: 1.0") var passer msgpasser.Passer passer.Init(9999) time.Sleep(3 * time.Second) cmd := exec.Command("python", "bSserver.py", os.Args[1], os.Args[2]) go cmd.Run() /*if err != nil { log.Println(err) }*/ time.Sleep(3 * time.Second) cmd2 := exec.Command("java", "-jar", "ttt.jar", os.Args[1], os.Args[2]) go cmd2.Run() /*if err != nil { log.Println(err) }*/ for { time.Sleep(30 * time.Second) log.Println("I am still alive!") } }
func main() { log.SetFlags(log.LstdFlags | log.Lshortfile) log.Println("Version: 1.0") var passer msgpasser.Passer passer.Init(9999) time.Sleep(3 * time.Second) /* addr, _ := net.ResolveUDPAddr("udp", "127.0.0.1:9999") conn, _ := net.DialUDP("udp", nil, addr) data := msgpasser.GameRoomData{"game room info", 0, nil, len(names), names[index]} data.Players = make([]msgpasser.PlayerInfo, len(names)) for i := range names { data.Players[i].Ip = addrs[i] data.Players[i].Name = names[i] } b, err := json.Marshal(&data) log.Println(string(b)) if err != nil { log.Println(err) } _, err = conn.Write(b) if err != nil { log.Println(err) }*/ for { time.Sleep(30 * time.Second) log.Println("I am still alive!") } }
func main() { log.SetFlags(log.LstdFlags | log.Lshortfile) log.Println("Version: 1.0") index, _ := strconv.Atoi(os.Args[1]) log.Println("index:", index) var passer msgpasser.Passer passer.Init(9999) time.Sleep(3 * time.Second) for z := 0; z < 30; z++ { log.Println("Start the", z, "round!") addr, _ := net.ResolveUDPAddr("udp", "127.0.0.1:9999") conn, _ := net.DialUDP("udp", nil, addr) data := msgpasser.GameRoomData{"game room info", 0, nil, len(names), names[index], "start", ""} data.Players = make([]msgpasser.PlayerInfo, len(names)) for i := range names { data.Players[i].Ip = addrs[i] data.Players[i].Name = names[i] } b, err := json.Marshal(&data) log.Println(string(b)) if err != nil { log.Println(err) } _, err = conn.Write(b) if err != nil { log.Println(err) } // To avoid too many input happen time.Sleep(10 * time.Second) x := 120 y := 3 for i := 0; i < x; i++ { for j := 0; j < y; j++ { msg := msgpasser.Data{fmt.Sprintf("%v %d", names[index], i*y+j), true} b, _ = json.Marshal(&msg) conn.Write(b) } time.Sleep(300 * time.Millisecond) } // time.Sleep(10 * time.Second) data = msgpasser.GameRoomData{"game room info", 0, nil, len(names), names[index], "close", ""} b, err = json.Marshal(&data) _, err = conn.Write(b) time.Sleep(10 * time.Second) log.Println("Finish the", z, "round!") } }
func main() { log.SetFlags(log.LstdFlags | log.Lshortfile) log.Println("Version: 1.0") var passer msgpasser.Passer passer.Init(9999) time.Sleep(3 * time.Second) for i, addrS := range addrs { addr, _ := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:9999", addrS)) conn, _ := net.DialUDP("udp", nil, addr) data := msgpasser.GameRoomData{"game room info", 0, nil, len(names), names[i], "join", localName} data.Players = make([]msgpasser.PlayerInfo, len(names)) for i := range names { data.Players[i].Ip = addrs[i] data.Players[i].Name = names[i] } b, err := json.Marshal(&data) log.Println(string(b)) if err != nil { log.Println(err) } _, err = conn.Write(b) if err != nil { log.Println(err) } } addr, _ := net.ResolveUDPAddr("udp", "127.0.0.1:9999") conn, _ := net.DialUDP("udp", nil, addr) // To avoid too many input happen time.Sleep(3 * time.Second) x := 10000 y := 3 for i := 0; i < x; i++ { for j := 0; j < y; j++ { msg := msgpasser.Data{fmt.Sprintf("%v %d", localName, i*y+j), true} b, _ := json.Marshal(&msg) conn.Write(b) } time.Sleep(300 * time.Millisecond) } for { time.Sleep(30 * time.Second) log.Println("I am still alive!") } }