Skip to content
This repository
Browse code

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

  • Loading branch information...
commit ff096199e316dd1f6da0e7c2a7dc0d1be97ef1ab 1 parent 3604097
Kenneth Kan authored August 19, 2012
6  src/components/Graph.coffee
@@ -53,8 +53,12 @@ class Graph extends noflo.Component
53 53
         return true
54 54
 
55 55
     replicatePort: (port) ->
  56
+        # Designate the destination port as a link to avoid sending multiple IPs
  57
+        port.isLink = true
  58
+
56 59
         return new noflo.ArrayPort() if port instanceof noflo.ArrayPort
57  
-        return new noflo.Port() unless port instanceof noflo.ArrayPort  
  60
+        return new noflo.Port() unless port instanceof noflo.ArrayPort
  61
+
58 62
     replicateInPort: (port, portName) ->
59 63
         newPort = @replicatePort port
60 64
         newPort.on "attach", (socket) ->
20  src/lib/ArrayPort.coffee
@@ -9,6 +9,10 @@ class ArrayPort extends port.Port
9 9
         @attachSocket socket
10 10
 
11 11
     connect: (socketId = null) ->
  12
+        # Send only once when this is a linking port between a graph and a subgraph
  13
+        if @isLink
  14
+          socketId = 0
  15
+
12 16
         if socketId is null
13 17
             @sockets.forEach (socket) ->
14 18
                 socket.disconnect()
@@ -20,6 +24,10 @@ class ArrayPort extends port.Port
20 24
         @sockets[socketId].disconnect()
21 25
 
22 26
     beginGroup: (group, socketId = null) ->
  27
+        # Send only once when this is a linking port between a graph and a subgraph
  28
+        if @isLink
  29
+          socketId = 0
  30
+
23 31
         if socketId is null
24 32
             @sockets.forEach (socket, index) =>
25 33
                 @beginGroup group, index
@@ -35,6 +43,10 @@ class ArrayPort extends port.Port
35 43
         @sockets[socketId].connect()
36 44
 
37 45
     send: (data, socketId = null) ->
  46
+        # Send only once when this is a linking port between a graph and a subgraph
  47
+        if @isLink
  48
+          socketId = 0
  49
+
38 50
         if socketId is null
39 51
             @sockets.forEach (socket, index) =>
40 52
                 @send data, index
@@ -50,6 +62,10 @@ class ArrayPort extends port.Port
50 62
         @sockets[socketId].connect()
51 63
 
52 64
     endGroup: (socketId = null) ->
  65
+        # Send only once when this is a linking port between a graph and a subgraph
  66
+        if @isLink
  67
+          socketId = 0
  68
+
53 69
         if socketId is null
54 70
             @sockets.forEach (socket, index) =>
55 71
                 @endGroup index
@@ -61,6 +77,10 @@ class ArrayPort extends port.Port
61 77
         do @sockets[socketId].endGroup
62 78
 
63 79
     disconnect: (socketId = null) ->
  80
+        # Send only once when this is a linking port between a graph and a subgraph
  81
+        if @isLink
  82
+          socketId = 0
  83
+
64 84
         if socketId is null
65 85
             @sockets.forEach (socket) ->
66 86
                 socket.disconnect()

0 notes on commit ff09619

Please sign in to comment.
Something went wrong with that request. Please try again.