Make MQTT key configurable #299
This commit is contained in:
parent
ce0d0fb29c
commit
66be351bd3
3 changed files with 6 additions and 4 deletions
|
|
@ -75,6 +75,7 @@ services:
|
|||
App\Service\MQTTClient:
|
||||
arguments:
|
||||
$redis_client: "@App\\Service\\RedisClientProvider"
|
||||
$key: "mqtt_events"
|
||||
|
||||
App\Service\APNSClient:
|
||||
arguments:
|
||||
|
|
|
|||
|
|
@ -9,14 +9,15 @@ class MQTTClient
|
|||
{
|
||||
const PREFIX = 'motolite.control.';
|
||||
const RIDER_PREFIX = 'motorider_';
|
||||
const REDIS_KEY = 'events';
|
||||
|
||||
// protected $mclient;
|
||||
protected $redis;
|
||||
protected $key;
|
||||
|
||||
public function __construct(RedisClientProvider $redis_client)
|
||||
public function __construct(RedisClientProvider $redis_client, $key)
|
||||
{
|
||||
$this->redis = $redis_client->getRedisClient();
|
||||
$this->key = $key;
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
|
|
@ -29,7 +30,7 @@ class MQTTClient
|
|||
// $this->mclient->publish($channel, $message);
|
||||
|
||||
$data = $channel . '|' . $message;
|
||||
$this->redis->lpush(self::REDIS_KEY, $data);
|
||||
$this->redis->lpush($this->key, $data);
|
||||
}
|
||||
|
||||
public function sendEvent(JobOrder $job_order, $payload)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ def redis_listen(client, logger):
|
|||
r = redis.StrictRedis(host='localhost', port=6379, db=0)
|
||||
while 1:
|
||||
time.sleep(0)
|
||||
data = r.brpop("events", 10)
|
||||
data = r.brpop("mqtt_events", 10)
|
||||
if data:
|
||||
info = data[1].split('|')
|
||||
logger.info("Channel: " + info[0] + " message: " + info[1])
|
||||
|
|
|
|||
Loading…
Reference in a new issue