mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 08:13:31 +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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user