Merge pull request #442 from slingamn/message_tags.5

upgrade message-tags to non-draft version
This commit is contained in:
Daniel Oaks
2019-03-12 08:47:08 +10:00
committed by GitHub
19 changed files with 200 additions and 313 deletions
+10 -16
View File
@@ -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()