File tree Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -32,13 +32,21 @@ angular.module('ngMQTT', [])
3232 var data = payload . toString ( ) ;
3333 }
3434 angular . forEach ( callbacks , function ( callback , name ) {
35- var regexpStr = name . replace ( new RegExp ( '(#)|(\\*)' ) , function ( str ) {
36- if ( str == "#" ) {
37- return ".*?"
38- } else if ( str == "*" ) {
39- return ".*?"
40- }
41- } ) ;
35+ var regexpStr = name . replace ( new RegExp ( '(#)|(\\*)|(\\+)' ) , function ( str ) {
36+ switch ( str ) {
37+ case "#" :
38+ return ".*?"
39+ break ;
40+ case "*" :
41+ return ".*?"
42+ break ;
43+ case "+" :
44+ return ".*"
45+ break ;
46+ default :
47+ break ;
48+ }
49+ } ) ;
4250 if ( topic . match ( regexpStr ) ) {
4351 $rootScope . $apply ( function ( ) {
4452 callback ( data , topic ) ;
@@ -56,5 +64,9 @@ angular.module('ngMQTT', [])
5664 Service . send = function ( name , data ) {
5765 client . publish ( name , JSON . stringify ( data ) ) ;
5866 } ;
67+ Service . drop = function ( name , callback ) {
68+ callbacks [ name ] = callback ;
69+ client . unsubscribe ( name ) ;
70+ } ;
5971 return Service ;
6072 } ] ) ;
You can’t perform that action at this time.
0 commit comments