1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 18:29:17 +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:
Simo Kinnunen 2015-06-25 16:35:26 +09:00
parent 2d9c432b62
commit fe7785f003

View file

@ -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)