Skip to content

Instantly share code, notes, and snippets.

@korutx
Last active October 29, 2016 15:48
Show Gist options
  • Save korutx/3b539b15104561ccbd2728dffbd3966b to your computer and use it in GitHub Desktop.
Save korutx/3b539b15104561ccbd2728dffbd3966b to your computer and use it in GitHub Desktop.
var client = mqtt.connect('ws://host:port', {
username: 'username',
clientId: 'client-id',
password: 'password'
});
client.subscribe('endpoint');
client.on('message', function (topic, payload) {
var evt = topic.toString(), args = payload.toString();
return _isJsonObj(args) && $rootScope.$broadcast(evt, JSON.parse(args));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment