|
|
|
@ -10,7 +10,7 @@ import ( |
|
|
|
|
"runtime/pprof" |
|
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
"bitbucket.org/hackerbots/botserv" |
|
|
|
|
hbserver "bitbucket.org/hackerbots/server" |
|
|
|
|
"code.google.com/p/go.net/websocket" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
@ -42,23 +42,23 @@ func main() { |
|
|
|
|
log.Println("serving profile info at http://localhost:8667/debug/pprof/") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
conf, err := botserv.LoadConfig(*config) |
|
|
|
|
conf, err := hbserver.LoadConfig(*config) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Fatal(err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sm := http.NewServeMux() |
|
|
|
|
|
|
|
|
|
c := botserv.NewController(conf, *mprofile, *profile) |
|
|
|
|
c := hbserver.NewController(conf, *mprofile, *profile) |
|
|
|
|
go c.Run() |
|
|
|
|
|
|
|
|
|
sm.Handle("/", botserv.JsonHandler(c.Index)) |
|
|
|
|
sm.Handle("/", hbserver.JsonHandler(c.Index)) |
|
|
|
|
sm.Handle("/ws/", websocket.Handler(c.AddPlayer)) |
|
|
|
|
sm.Handle("/game/start/", botserv.JsonHandler(c.StartGame)) |
|
|
|
|
sm.Handle("/game/list/", botserv.JsonHandler(c.ListGames)) |
|
|
|
|
sm.Handle("/game/stats/", botserv.JsonHandler(c.GameStats)) |
|
|
|
|
sm.Handle("/game/bw/", botserv.JsonHandler(c.BW)) |
|
|
|
|
sm.Handle("/game/stop/", botserv.JsonHandler(c.StopGame)) |
|
|
|
|
sm.Handle("/game/start/", hbserver.JsonHandler(c.StartGame)) |
|
|
|
|
sm.Handle("/game/list/", hbserver.JsonHandler(c.ListGames)) |
|
|
|
|
sm.Handle("/game/stats/", hbserver.JsonHandler(c.GameStats)) |
|
|
|
|
sm.Handle("/game/bw/", hbserver.JsonHandler(c.BW)) |
|
|
|
|
sm.Handle("/game/stop/", hbserver.JsonHandler(c.StopGame)) |
|
|
|
|
sm.HandleFunc("/fuck/shit/up/", c.KillServer) |
|
|
|
|
|
|
|
|
|
err = http.ListenAndServe(*addr, sm) |
|
|
|
|