1
0

protocol.py 1.0 KB

1234567891011121314151617181920212223242526
  1. # The contents of this file are subject to the Python Software Foundation
  2. # License Version 2.3 (the License). You may not copy or use this file, in
  3. # either source code or executable form, except in compliance with the License.
  4. # You may obtain a copy of the License at http://www.python.org/license.
  5. #
  6. # Software distributed under the License is distributed on an AS IS basis,
  7. # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  8. # for the specific language governing rights and limitations under the
  9. # License.
  10. #
  11. # by Greg Hazel
  12. from twisted.internet import protocol
  13. from BTL.decorate import decorate_func
  14. ## someday twisted might do this for me
  15. class SmartReconnectingClientFactory(protocol.ReconnectingClientFactory):
  16. def buildProtocol(self, addr):
  17. prot = protocol.ReconnectingClientFactory.buildProtocol(self, addr)
  18. # decorate the protocol with a delay reset
  19. prot.connectionMade = decorate_func(self.resetDelay,
  20. prot.connectionMade)
  21. return prot