mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 08:03:30 +02:00
Fix direct device control not extending owner timeout.
This commit is contained in:
@@ -8,13 +8,27 @@ function ChannelManager() {
|
||||
|
||||
util.inherits(ChannelManager, events.EventEmitter)
|
||||
|
||||
ChannelManager.prototype.register = function(id, timeout) {
|
||||
this.channels[id] = {
|
||||
timeout: timeout
|
||||
ChannelManager.prototype.register = function(id, options) {
|
||||
var channel = this.channels[id] = {
|
||||
timeout: options.timeout
|
||||
, alias: options.alias
|
||||
, lastActivity: Date.now()
|
||||
, timer: null
|
||||
}
|
||||
|
||||
if (channel.alias) {
|
||||
// The alias can only be active for a single channel at a time
|
||||
if (this.channels[channel.alias]) {
|
||||
throw new Error(util.format(
|
||||
'Cannot create alias "%s" for "%s"; the channel already exists'
|
||||
, channel.alias
|
||||
, id
|
||||
))
|
||||
}
|
||||
|
||||
this.channels[channel.alias] = channel
|
||||
}
|
||||
|
||||
// Set timer with initial check
|
||||
this.check(id)
|
||||
}
|
||||
@@ -24,6 +38,9 @@ ChannelManager.prototype.unregister = function(id) {
|
||||
if (channel) {
|
||||
delete this.channels[id]
|
||||
clearTimeout(channel.timer)
|
||||
if (channel.alias) {
|
||||
delete this.channels[channel.alias]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user