<div dir="ltr">Hello, I&#39;m trying to understand how can I use Perspective Broker to send <div>some data getted from a TCP listener to another process...</div><div><br></div><div style>I can&#39;t figure out how to get it....</div>
<div><div><br></div><div><br></div><div><div>from twisted.internet import protocol, reactor</div><div>from twisted.python import log</div><div><br></div><div>from twisted.spread import pb</div><div><br></div><div><br></div>
<div>class Service(protocol.Protocol):</div><div>    extra = {}<span class="" style="white-space:pre">                                                </span></div><div><span style="white-space:pre">    </span>def dataReceived(self, data):</div><div><span style="white-space:pre">        </span>extra = doSomething(data)</div>
<div><span class="" style="white-space:pre">                </span></div><div><span style="white-space:pre">        </span>#SEND extra TO ANOTHER PROCESS -- FAILED CODE</div><div><div><span style="white-space:pre">         factory = pb.PBClientFactory()</span></div>
<div><span style="white-space:pre">         reactor.connectTCP(&quot;localhost&quot;, 8798, factory)</span></div><div><span style="white-space:pre">         root = factory.getRootObject()</span></div><div><span style="white-space:pre"><br>
</span></div><div><span style="white-space:pre">          def got_root(root):</span></div><div><span style="white-space:pre">              rc = root.callRemote(&quot;get&quot;, data)</span></div><div><span style="white-space:pre">              def got_value(v):</span></div>
<div><span style="white-space:pre">                  print v</span></div><div><span style="white-space:pre">                  reactor.stop()</span></div><div><span style="white-space:pre">              rc.addCallback(got_value)</span></div>
<div><span style="white-space:pre"><br></span></div><div><span style="white-space:pre">          root.addCallback(got_root)</span></div><div><span style="white-space:pre">          reactor.run()</span></div></div><div>                ....</div>
<div><br></div><div>class ServerFactory(protocol.Factory):<span class="" style="white-space:pre">                                                                                </span><br></div><div>    def buildProtocol(self, addr):</div><div>        return Service()</div><div><br></div><div>
reactor.listenTCP(8797, ServerFactory())<span class="" style="white-space:pre">                                                                </span></div><div>reactor.run()</div></div></div><div><br></div><div style>This testing code fails, I know I&#39;m wrong, please could somebody help me to understand and get it?</div>
<div style>Thanks in advance.</div><div style>Christian Espinoza. </div></div>