Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure requests get a response #111

Merged
merged 1 commit into from
Mar 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 35 additions & 14 deletions src/protocol/Network.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,25 @@ class NetworkProtocol extends EventEmitter
return

stopNetwork: (graph, payload, context) ->
return unless @networks[payload.graph]
unless @networks[payload.graph]
@send 'error', new Error("Network #{payload.graph} not found"), context
return
net = @networks[payload.graph].network
return unless net
unless net
@send 'error', new Error("Network #{payload.graph} not found"), context
return
if net.isStarted()
@networks[payload.graph].network.stop (err) =>
return @send 'error', err, context if err
if err
@send 'error', err, context
return
@send 'stopped',
time: new Date
graph: payload.graph
running: net.isRunning()
started: net.isStarted()
, context
return
return
# Was already stopped, just send the confirmation
@send 'stopped',
Expand All @@ -238,22 +251,30 @@ class NetworkProtocol extends EventEmitter
, context

debugNetwork: (graph, payload, context) ->
return unless @networks[payload.graph]
unless @networks[payload.graph]
@send 'error', new Error("Network #{payload.graph} not found"), context
return
net = @networks[payload.graph].network
return unless net
if net.setDebug?
net.setDebug payload.enable
else
console.log 'Warning: Network.setDebug not supported. Update to newer NoFlo'
unless net
@send 'error', new Error("Network #{payload.graph} not found"), context
return
net.setDebug payload.enable
@send 'setdebug',
enable: payload.enable
return

getStatus: (graph, payload, context) ->
return unless @networks[payload.graph]
unless @networks[payload.graph]
@send 'error', new Error("Network #{payload.graph} not found"), context
return
net = @networks[payload.graph].network
return unless net
unless net
@send 'error', new Error("Network #{payload.graph} not found"), context
return
@send 'status',
graph: payload.graph
running: net.isRunning()
started: net.isStarted()
graph: payload.graph
running: net.isRunning()
started: net.isStarted()
, context

module.exports = NetworkProtocol
1 change: 1 addition & 0 deletions src/protocol/Runtime.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class RuntimeProtocol extends EventEmitter
when 'packet' then @sendPacket payload, (err) =>
if err
@sendError err.message, context
# TODO: Ack packet send
return

getRuntime: (payload, context) ->
Expand Down