removing some extra fields

master
Jordan Orelli 4 years ago
parent 6192d01bb8
commit 9c90e4bece

@ -19,8 +19,6 @@ import (
type Server struct { type Server struct {
*blammo.Log *blammo.Log
Host string
Port int
http *http.Server http *http.Server
world *sim.World world *sim.World
@ -30,13 +28,7 @@ type Server struct {
waitOnSessions sync.WaitGroup waitOnSessions sync.WaitGroup
} }
func (s *Server) Start() error { func (s *Server) Start(host string, port int) error {
if s.Host == "" {
s.Host = "127.0.0.1"
}
if s.Port == 0 {
s.Port = 12805
}
if s.Log == nil { if s.Log == nil {
stdout := blammo.NewLineWriter(os.Stdout) stdout := blammo.NewLineWriter(os.Stdout)
stderr := blammo.NewLineWriter(os.Stderr) stderr := blammo.NewLineWriter(os.Stderr)
@ -53,7 +45,7 @@ func (s *Server) Start() error {
s.world = sim.NewWorld(s.Log.Child("world")) s.world = sim.NewWorld(s.Log.Child("world"))
go s.world.Run(3) go s.world.Run(3)
addr := fmt.Sprintf("%s:%d", s.Host, s.Port) addr := fmt.Sprintf("%s:%d", host, port)
lis, err := net.Listen("tcp", addr) lis, err := net.Listen("tcp", addr)
if err != nil { if err != nil {
return fmt.Errorf("server failed to start a listener: %w", err) return fmt.Errorf("server failed to start a listener: %w", err)

@ -38,7 +38,7 @@ func main() {
runClient(os.Args[2]) runClient(os.Args[2])
case "server": case "server":
s := server.Server{} s := server.Server{}
if err := s.Start(); err != nil { if err := s.Start("127.0.0.1", 12805); err != nil {
exit.WithMessage(1, "unable to start server: %v", err) exit.WithMessage(1, "unable to start server: %v", err)
} }
sig := make(chan os.Signal, 1) sig := make(chan os.Signal, 1)

Loading…
Cancel
Save