/**
 * Created by shellus on 2016-03-16.
 */
angular.module('ngMQTT', [])
    .config(['$provide', function($provide){
        $provide.provider('MQTT', function(){

            var settings = {
                href: ""
            };

            this.setHref = function(href){
                settings.href = href;
            };
            this.$get = function() {
                return settings;
            };
        });
    }])

    .service('MQTTService',
        ['$q', '$rootScope', 'MQTT', function($q, $rootScope, MQTT) {
            var Service = {};
            var callbacks = {};

            var client = mqtt.connect(MQTT.href); // you add a ws:// url here

            client.on("message", function(topic, payload) {
                try {
                    var data = JSON.parse(payload.toString());
                }catch (e){
                    throw new Error("received data can not parse for JSON !");
                }
                angular.forEach(callbacks,function(callback, name){
                    var regexpStr = name.replace(new RegExp('(#)|(\\*)'),function(str){
                        if(str=="#"){
                            return ".*?"
                        }else if(str=="*"){
                            return ".*?"
                        }
                    });
                    if(topic.match(regexpStr)){
                        $rootScope.$apply(function() {
                            callback(data);
                        });
                    }
                })
            });

            client.publish("time", (new Date()).getDate());

            Service.on = function(name, callback){
                callbacks[name] = callback;
                client.subscribe(name);
            };
            Service.send = function(name, data){
                client.publish(name, JSON.stringify(data));
            };
            Service.drop = function(name, callback){
                callbacks[name] = callback;
                client.unsubscribe(name);
            };
            return Service;
        }]);

@@ -868,64 +868,36 @@
     
-throw new Error(%22received data can not parse for JSON !%22
+var data = payload.toString(
 );%0A 
@@ -1051,16 +1051,22 @@
 #)%7C(%5C%5C*)
+%7C(%5C%5C+)
 '),funct
@@ -1101,26 +1101,57 @@
     
-  if(str==%22#%22)
+switch (str) 
 %7B%0A  
+                      case %22#%22:%0A
     
@@ -1213,30 +1213,157 @@
     
-%7Delse if(str==%22*%22)%7B%0A  
+  break;%0A                        case %22*%22:%0A                          return %22.*?%22%0A                          break;%0A                        case %22+%22:%0A
     
@@ -1386,33 +1386,32 @@
       return %22.*
-?
 %22%0A              
@@ -1412,36 +1412,129 @@
                 
-%7D%0A
   
+break;%0A                        default:%0A                          break;%0A                    %7D%0A
                 

Add management for plus character in topic string.