Created
April 15, 2016 08:15
-
-
Save mwittig/489dade58a8fa673e253f9c65a869618 to your computer and use it in GitHub Desktop.
pimatic callAction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
action: (deviceId, actionName, params) -> | |
id = '' + @_getActionId() | |
p = if params? then params else {} | |
p.deviceId = deviceId | |
p.actionName = actionName | |
new Promise (resolve, reject) => | |
@socket.emit 'call', { | |
id: id, | |
action: 'callDeviceAction', | |
params: p | |
} | |
@socket.on 'callResult', (result) => | |
console.log "###################", result | |
if result.id is id | |
if result.success | |
resolve() | |
else | |
reject result.error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment