mirror of
https://github.com/jeremyd/ergo.git
synced 2026-07-17 13:08:11 -07:00
do idle in the server goroutine instead of the timeout goroutine
This commit is contained in:
+5
-5
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user