File modules/cms/generator/dsl/DslMqtt.class.php
Last commit: Mon Jun 27 00:40:42 2022 +0200 Jan Dankert New: Marker interface 'Scriptable', Proxy class for MQTT, help() method in Scripts.
1 <?php 2 3 namespace cms\generator\dsl; 4 5 use dsl\context\BaseScriptableObject; 6 use dsl\context\Scriptable; 7 use util\Http; 8 use util\json\JSON; 9 use util\Mqtt; 10 11 /** 12 * A Proxy for MqTT methods. 13 */ 14 class DslMqtt extends BaseScriptableObject 15 { 16 /** 17 * @var Mqtt 18 */ 19 private $mqtt; 20 21 22 public function __construct($url,$user,$password ) 23 { 24 $this->mqtt = new Mqtt( $url ); 25 $this->mqtt->connect( $user, $password ); 26 } 27 28 public function publish($topic,$value) 29 { 30 $this->mqtt->publish($topic,$value); 31 } 32 33 public function subscribe($topic) 34 { 35 return $this->mqtt->subscribe($topic); 36 } 37 38 public function disconnect() 39 { 40 $this->mqtt->disconnect(); 41 } 42 }
Downloadmodules/cms/generator/dsl/DslMqtt.class.php
History Mon, 27 Jun 2022 00:40:42 +0200 Jan Dankert New: Marker interface 'Scriptable', Proxy class for MQTT, help() method in Scripts.