mirror of
https://github.com/openstf/stf
synced 2025-10-04 10:19:30 +02:00
Keep the same channel for each device. This should make it easier to keep the client side up to date after device death (because there's no need to update it at all).
This commit is contained in:
parent
2d9c432b62
commit
fe7785f003
1 changed files with 12 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
|||
var crypto = require('crypto')
|
||||
|
||||
var syrup = require('stf-syrup')
|
||||
|
||||
var logger = require('../../../util/logger')
|
||||
|
@ -11,7 +13,16 @@ module.exports = syrup.serial()
|
|||
.dependency(require('./identity'))
|
||||
.define(function(options, sub, push, router, identity) {
|
||||
var log = logger.createLogger('device:plugins:solo')
|
||||
var channel = wireutil.makePrivateChannel()
|
||||
|
||||
// The channel should keep the same value between restarts, so that
|
||||
// having the client side up to date all the time is not horribly painful.
|
||||
function makeChannelId() {
|
||||
var hash = crypto.createHash('sha1')
|
||||
hash.update(options.serial)
|
||||
return hash.digest('base64')
|
||||
}
|
||||
|
||||
var channel = makeChannelId()
|
||||
|
||||
log.info('Subscribing to permanent channel "%s"', channel)
|
||||
sub.subscribe(channel)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue