1
0
Fork 0
forked from External/grumble

Add a running state to the server object

This commit is contained in:
Benjamin Jemlich 2011-04-26 02:55:23 +08:00 committed by Mikkel Krautz
parent f25751d1aa
commit 8ff0a15bcf

View file

@ -47,6 +47,7 @@ type Server struct {
address string address string
port int port int
udpconn *net.UDPConn udpconn *net.UDPConn
running bool
incoming chan *Message incoming chan *Message
udpsend chan *Message udpsend chan *Message
@ -100,6 +101,7 @@ func NewServer(id int64, addr string, port int) (s *Server, err os.Error) {
s.Id = id s.Id = id
s.address = addr s.address = addr
s.port = port s.port = port
s.running = false
s.clients = make(map[uint32]*Client) s.clients = make(map[uint32]*Client)
s.Users = make(map[uint32]*User) s.Users = make(map[uint32]*User)
@ -995,6 +997,8 @@ func (s *Server) ListenAndMurmur() {
// Launch the event handler goroutine // Launch the event handler goroutine
go s.handler() go s.handler()
s.running = true
// Setup our UDP listener and spawn our reader and writer goroutines // Setup our UDP listener and spawn our reader and writer goroutines
s.SetupUDP() s.SetupUDP()
go s.ListenUDP() go s.ListenUDP()