Przeglądaj źródła

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)
tags/v1.0.0-rc1
Shivaram Lingamneni 5 lat temu
rodzic
commit
a4b3fb0e83
2 zmienionych plików z 20 dodań i 27 usunięć
  1. 0
    6
      irc/client.go
  2. 20
    21
      irc/commands.go

+ 0
- 6
irc/client.go Wyświetl plik

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

+ 20
- 21
irc/commands.go Wyświetl plik

@@ -12,13 +12,12 @@ import (
12 12
 
13 13
 // Command represents a command accepted from a client.
14 14
 type Command struct {
15
-	handler           func(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool
16
-	oper              bool
17
-	usablePreReg      bool
18
-	leaveClientActive bool // if true, leaves the client active time alone. reversed because we can't default a struct element to True
19
-	leaveClientIdle   bool
20
-	minParams         int
21
-	capabs            []string
15
+	handler         func(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool
16
+	oper            bool
17
+	usablePreReg    bool
18
+	leaveClientIdle bool // if true, leaves the client active time alone
19
+	minParams       int
20
+	capabs          []string
22 21
 }
23 22
 
24 23
 // Run runs this command with the given client/message.
@@ -54,11 +53,10 @@ func (cmd *Command) Run(server *Server, client *Client, msg ircmsg.IrcMessage) b
54 53
 		server.tryRegister(client)
55 54
 	}
56 55
 
57
-	if !cmd.leaveClientIdle {
58
-		client.Touch()
59
-	}
56
+	// most servers do this only for PING/PONG, but we'll do it for any command:
57
+	client.idletimer.Touch()
60 58
 
61
-	if !cmd.leaveClientActive {
59
+	if !cmd.leaveClientIdle {
62 60
 		client.Active()
63 61
 	}
64 62
 
@@ -118,8 +116,9 @@ func init() {
118 116
 			minParams: 2,
119 117
 		},
120 118
 		"ISON": {
121
-			handler:   isonHandler,
122
-			minParams: 1,
119
+			handler:         isonHandler,
120
+			minParams:       1,
121
+			leaveClientIdle: true,
123 122
 		},
124 123
 		"JOIN": {
125 124
 			handler:   joinHandler,
@@ -200,16 +199,16 @@ func init() {
200 199
 			minParams:    1,
201 200
 		},
202 201
 		"PING": {
203
-			handler:           pingHandler,
204
-			usablePreReg:      true,
205
-			minParams:         1,
206
-			leaveClientActive: true,
202
+			handler:         pingHandler,
203
+			usablePreReg:    true,
204
+			minParams:       1,
205
+			leaveClientIdle: true,
207 206
 		},
208 207
 		"PONG": {
209
-			handler:           pongHandler,
210
-			usablePreReg:      true,
211
-			minParams:         1,
212
-			leaveClientActive: true,
208
+			handler:         pongHandler,
209
+			usablePreReg:    true,
210
+			minParams:       1,
211
+			leaveClientIdle: true,
213 212
 		},
214 213
 		"PRIVMSG": {
215 214
 			handler:   privmsgHandler,

Ładowanie…
Anuluj
Zapisz