title: Persistent connection in twisted
body: <p>I'm new in Twisted and have one question. How can I organize a persistent connection in Twisted? I have a queue and every second checks it. If have some - send on client. I can't find something better than call dataReceived every second.
  Here is the code of Protocol implementation:</p>
  
  <pre class="lang-py prettyprint-override"><code>class SyncProtocol(protocol.Protocol):
      # ... some code here
      def dataReceived(self, data):
          if(self.orders_queue.has_new_orders()):
              for order in self.orders_queue:
                  self.transport.write(str(order))
  
          reactor.callLater(1, self.dataReceived, data)  # 1 second delay
  </code></pre>
  
  <p>It works how I need, but I'm sure that it is very bad solution. How can I do that in different way (flexible and correct)? Thanks.</p>
  
  <p>P.S. - the main idea and alghorithm:
  1. Client connect to server and wait
  2. Server checks for update and pushes data to client if anything changes
  3. Client do some operations and then wait for other data</p>