File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ angular.module('ngMQTT', [])
2929 try {
3030 var data = JSON . parse ( payload . toString ( ) ) ;
3131 } catch ( e ) {
32- var data = payload . toString ( ) ;
32+ throw new Error ( "received data can not parse for JSON !" ) ;
3333 }
3434 angular . forEach ( callbacks , function ( callback , name ) {
3535 var regexpStr = name . replace ( new RegExp ( '(#)|(\\*)' ) , function ( str ) {
@@ -41,7 +41,7 @@ angular.module('ngMQTT', [])
4141 } ) ;
4242 if ( topic . match ( regexpStr ) ) {
4343 $rootScope . $apply ( function ( ) {
44- callback ( data , topic ) ;
44+ callback ( data ) ;
4545 } ) ;
4646 }
4747 } )
@@ -56,5 +56,9 @@ angular.module('ngMQTT', [])
5656 Service . send = function ( name , data ) {
5757 client . publish ( name , JSON . stringify ( data ) ) ;
5858 } ;
59+ Service . drop = function ( name , callback ) {
60+ callbacks [ name ] = callback ;
61+ client . unsubscribe ( name ) ;
62+ } ;
5963 return Service ;
6064 } ] ) ;
You can’t perform that action at this time.
0 commit comments