<?php

/**
 * To run this use this command: php index.php App\Controllers\MosquittoMqttService\PublishMqttController index
 */
namespace App\Controllers\MosquittoMqttService;

require_once APPPATH . 'Libraries/CommunicationProtocol/MosquittoMqtt.php';

use App\Controllers\BaseController;
use Libraries\CommunicationProtocol\MosquittoMqtt;

class PublishMqttController extends BaseController {
    
    public function index() {
        
        $objMosquittoMqtt = new MosquittoMqtt();
        
        $objMosquittoMqtt->getConnection();

        $strMessage = 'This is akshay. How are you?';

        $objMosquittoMqtt->publish( 'diioT-1/soyorms/publis/', $strMessage );
        
        $objMosquittoMqtt->disconnectConnection();
        
        echo 'Topic has been successfully published' . PHP_EOL;
        
    }
   
}
