main.go 656 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package main
  2. import (
  3. "encoding/json"
  4. "log"
  5. "os"
  6. "battlecamp-go-server/stomp"
  7. "battlecamp-go-server/flag"
  8. "battlecamp-go-server/events"
  9. )
  10. var Server *string
  11. func main() {
  12. initLogging()
  13. log.Println("Game bot version 0.1")
  14. flag.ParseFlags()
  15. sub := stomp.Subscribe("game")
  16. for {
  17. announcement := <- sub
  18. gs := new(events.GameStart)
  19. json.Unmarshal(announcement.Body, &gs)
  20. log.Printf("announcement type: %v ", gs.Type)
  21. }
  22. }
  23. func initLogging() {
  24. logFile, err := os.Create("server.log")
  25. if err == nil {
  26. log.SetOutput(logFile)
  27. } else {
  28. log.Println("ERROR: Cannot open log file, using console.")
  29. log.Printf("%v=n", err)
  30. }
  31. }