You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
588 B
38 lines
588 B
/**
|
|
* Created by GoLand.
|
|
* User: link1st
|
|
* Date: 2019-07-31
|
|
* Time: 15:17
|
|
*/
|
|
|
|
package task
|
|
|
|
import (
|
|
"fmt"
|
|
"gowebsocket/servers/websocket"
|
|
"runtime/debug"
|
|
"time"
|
|
)
|
|
|
|
func Init() {
|
|
Timer(3*time.Second, 30*time.Second, cleanConnection, "", nil, nil)
|
|
|
|
}
|
|
|
|
// 清理超时连接
|
|
func cleanConnection(param interface{}) (result bool) {
|
|
result = true
|
|
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
fmt.Println("ClearTimeoutConnections stop", r, string(debug.Stack()))
|
|
}
|
|
}()
|
|
|
|
fmt.Println("定时任务,清理超时连接", param)
|
|
|
|
websocket.ClearTimeoutConnections()
|
|
|
|
return
|
|
}
|