Permalink
Browse files

Make sure IPs are only sent once when sending to ArrayPort on a subgraph

  • Loading branch information...
1 parent 3604097 commit ff096199e316dd1f6da0e7c2a7dc0d1be97ef1ab @kenhkan kenhkan committed Aug 19, 2012
Showing with 25 additions and 1 deletion.
  1. +5 −1 src/components/Graph.coffee
  2. +20 −0 src/lib/ArrayPort.coffee
@@ -53,8 +53,12 @@ class Graph extends noflo.Component
return true
replicatePort: (port) ->
+ # Designate the destination port as a link to avoid sending multiple IPs
+ port.isLink = true
+
return new noflo.ArrayPort() if port instanceof noflo.ArrayPort
- return new noflo.Port() unless port instanceof noflo.ArrayPort
+ return new noflo.Port() unless port instanceof noflo.ArrayPort
+
replicateInPort: (port, portName) ->
newPort = @replicatePort port
newPort.on "attach", (socket) ->
View
@@ -9,6 +9,10 @@ class ArrayPort extends port.Port
@attachSocket socket
connect: (socketId = null) ->
+ # Send only once when this is a linking port between a graph and a subgraph
+ if @isLink
+ socketId = 0
+
if socketId is null
@sockets.forEach (socket) ->
socket.disconnect()
@@ -20,6 +24,10 @@ class ArrayPort extends port.Port
@sockets[socketId].disconnect()
beginGroup: (group, socketId = null) ->
+ # Send only once when this is a linking port between a graph and a subgraph
+ if @isLink
+ socketId = 0
+
if socketId is null
@sockets.forEach (socket, index) =>
@beginGroup group, index
@@ -35,6 +43,10 @@ class ArrayPort extends port.Port
@sockets[socketId].connect()
send: (data, socketId = null) ->
+ # Send only once when this is a linking port between a graph and a subgraph
+ if @isLink
+ socketId = 0
+
if socketId is null
@sockets.forEach (socket, index) =>
@send data, index
@@ -50,6 +62,10 @@ class ArrayPort extends port.Port
@sockets[socketId].connect()
endGroup: (socketId = null) ->
+ # Send only once when this is a linking port between a graph and a subgraph
+ if @isLink
+ socketId = 0
+
if socketId is null
@sockets.forEach (socket, index) =>
@endGroup index
@@ -61,6 +77,10 @@ class ArrayPort extends port.Port
do @sockets[socketId].endGroup
disconnect: (socketId = null) ->
+ # Send only once when this is a linking port between a graph and a subgraph
+ if @isLink
+ socketId = 0
+
if socketId is null
@sockets.forEach (socket) ->
socket.disconnect()

0 comments on commit ff09619

Please sign in to comment.