mirror of
https://github.com/jeremyd/ergo.git
synced 2026-07-30 02:38:11 -07:00
Merge pull request #442 from slingamn/message_tags.5
upgrade message-tags to non-draft version
This commit is contained in:
+10
-16
@@ -54,14 +54,17 @@ type IdleTimer struct {
|
||||
timer *time.Timer
|
||||
}
|
||||
|
||||
// NewIdleTimer sets up a new IdleTimer using constant timeouts.
|
||||
func NewIdleTimer(client *Client) *IdleTimer {
|
||||
it := IdleTimer{
|
||||
registerTimeout: RegisterTimeout,
|
||||
client: client,
|
||||
}
|
||||
// Initialize sets up an IdleTimer and starts counting idle time;
|
||||
// if there is no activity from the client, it will eventually be stopped.
|
||||
func (it *IdleTimer) Initialize(client *Client) {
|
||||
it.client = client
|
||||
it.registerTimeout = RegisterTimeout
|
||||
it.idleTimeout, it.quitTimeout = it.recomputeDurations()
|
||||
return &it
|
||||
|
||||
it.Lock()
|
||||
defer it.Unlock()
|
||||
it.state = TimerUnregistered
|
||||
it.resetTimeout()
|
||||
}
|
||||
|
||||
// recomputeDurations recomputes the idle and quit durations, given the client's caps.
|
||||
@@ -82,15 +85,6 @@ func (it *IdleTimer) recomputeDurations() (idleTimeout, quitTimeout time.Duratio
|
||||
return
|
||||
}
|
||||
|
||||
// Start starts counting idle time; if there is no activity from the client,
|
||||
// it will eventually be stopped.
|
||||
func (it *IdleTimer) Start() {
|
||||
it.Lock()
|
||||
defer it.Unlock()
|
||||
it.state = TimerUnregistered
|
||||
it.resetTimeout()
|
||||
}
|
||||
|
||||
func (it *IdleTimer) Touch() {
|
||||
idleTimeout, quitTimeout := it.recomputeDurations()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user