Skip to content

shellus/angular-MQTT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

angular-MQTT

This project is based on https://github.com/mqttjs/MQTT.js#browser

USE

bower install angular-mqtt
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-mqtt/src/browserMqtt.js"></script>
<script src="bower_components/angular-mqtt/src/angular-MQTT.js"></script>
    var app = angular.module('app', [
        'ngMQTT'
    ]);

    app.config(['MQTTProvider',function(MQTTProvider){
        MQTTProvider.setHref('ws://cv.endaosi.com:18585');
    }]);

    app.controller('indexCtrl', ['$scope', 'MQTTService', function ($scope, MQTTService) {
        MQTTService.on('hello', function(data){
            alert(data)
        });


        MQTTService.send('hello','word');
        MQTTService.send('hello','word1');
        MQTTService.send('hello','word2');
    }]);

##TODO

  • add auth

MQTT server install mothod see: http://blog.csdn.net/qhdcsj/article/details/45042515