do idle in the server goroutine instead of the timeout goroutine

This commit is contained in:
Jeremy Latt
2014-02-18 11:22:56 -08:00
parent 4f106e7d3e
commit 2bc1b952a0
2 changed files with 11 additions and 13 deletions
+5 -5
View File
@@ -19,6 +19,7 @@ type Server struct {
commands chan Command
conns chan net.Conn
ctime time.Time
idle chan *Client
motdFile string
name string
operators map[string]string
@@ -33,6 +34,7 @@ func NewServer(config *Config) *Server {
commands: make(chan Command),
conns: make(chan net.Conn),
ctime: time.Now(),
idle: make(chan *Client),
motdFile: config.MOTD,
name: config.Name,
operators: make(map[string]string),
@@ -60,6 +62,9 @@ func (server *Server) ReceiveCommands() {
case client := <-server.toDestroy:
client.Destroy()
case client := <-server.idle:
client.Idle()
case cmd := <-server.commands:
client := cmd.Client()
if DEBUG_SERVER {
@@ -650,11 +655,6 @@ func (msg *ListCommand) HandleServer(server *Server) {
client.Reply(RplListEnd(server))
}
func (msg *ClientIdle) HandleServer(server *Server) {
client := msg.Client()
client.Reply(RplPing(server, client))
}
func (msg *NamesCommand) HandleServer(server *Server) {
client := msg.Client()
if len(server.channels) == 0 {