Skip to content

Commit

Permalink
0.6.1 improved docs and error handling on websocket card
Browse files Browse the repository at this point in the history
  • Loading branch information
irritanterik committed Apr 11, 2016
1 parent d55779a commit a40e980
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,17 +251,20 @@ function flow_actions() {
Homey.log('webSocket Send action. Passed parameters: ', args)
var url = args.url
var data = args.data
var ws = new webSocket(url)

try {
var ws = new webSocket(url)
} catch(error) {
return callback(error)
}

ws.on('open', function() {
ws.send(data, function(){
ws.close()
Homey.log(' webSocket Send action completed.')
callback( null, true)
})
})

ws.on('error', function(error) {
}).on('error', function(error) {
Homey.log(' webSocket Send action failed:', error)
callback(error)
})
Expand Down

0 comments on commit a40e980

Please sign in to comment.