changes to client idle time counting

1. Remove leaveClientIdle (unused)
2. s/leaveClientActive/leaveClientIdle/
3. make ISON a leaveClientIdle command (some clients send it periodically
   if a /msg window is left open)
This commit is contained in:
Shivaram Lingamneni 2018-12-30 18:05:27 -05:00
parent ba2aacaf5b
commit a4b3fb0e83
2 changed files with 20 additions and 27 deletions

View File

@ -332,12 +332,6 @@ func (client *Client) Active() {
client.atime = time.Now() client.atime = time.Now()
} }
// Touch marks the client as alive (as it it has a connection to us and we
// can receive messages from it).
func (client *Client) Touch() {
client.idletimer.Touch()
}
// Ping sends the client a PING message. // Ping sends the client a PING message.
func (client *Client) Ping() { func (client *Client) Ping() {
client.Send(nil, "", "PING", client.nick) client.Send(nil, "", "PING", client.nick)

View File

@ -15,8 +15,7 @@ type Command struct {
handler func(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool handler func(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool
oper bool oper bool
usablePreReg bool usablePreReg bool
leaveClientActive bool // if true, leaves the client active time alone. reversed because we can't default a struct element to True leaveClientIdle bool // if true, leaves the client active time alone
leaveClientIdle bool
minParams int minParams int
capabs []string capabs []string
} }
@ -54,11 +53,10 @@ func (cmd *Command) Run(server *Server, client *Client, msg ircmsg.IrcMessage) b
server.tryRegister(client) server.tryRegister(client)
} }
if !cmd.leaveClientIdle { // most servers do this only for PING/PONG, but we'll do it for any command:
client.Touch() client.idletimer.Touch()
}
if !cmd.leaveClientActive { if !cmd.leaveClientIdle {
client.Active() client.Active()
} }
@ -120,6 +118,7 @@ func init() {
"ISON": { "ISON": {
handler: isonHandler, handler: isonHandler,
minParams: 1, minParams: 1,
leaveClientIdle: true,
}, },
"JOIN": { "JOIN": {
handler: joinHandler, handler: joinHandler,
@ -203,13 +202,13 @@ func init() {
handler: pingHandler, handler: pingHandler,
usablePreReg: true, usablePreReg: true,
minParams: 1, minParams: 1,
leaveClientActive: true, leaveClientIdle: true,
}, },
"PONG": { "PONG": {
handler: pongHandler, handler: pongHandler,
usablePreReg: true, usablePreReg: true,
minParams: 1, minParams: 1,
leaveClientActive: true, leaveClientIdle: true,
}, },
"PRIVMSG": { "PRIVMSG": {
handler: privmsgHandler, handler: privmsgHandler,