Changes between Version 42 and Version 43 of FrequentlyAskedQuestions


Ignore:
Timestamp:
08/24/11 18:43:16 (10 years ago)
Author:
Itamar Turner-Trauring
Comment:

Explicit buildProtocol is more informative

Legend:

Unmodified
Added
Removed
Modified
  • FrequentlyAskedQuestions

    v42 v43  
    103103
    104104class MultiEcho(Protocol):
     105    def __init__(self, factory):
     106        self.factory = factory
     107
    105108    def connectionMade(self):
    106109        self.factory.echoers.append(self)
     110
    107111    def dataReceived(self, data):
    108112        for echoer in self.factory.echoers:
    109113            echoer.transport.write(data)
     114
    110115    def connectionLost(self, reason):
    111116        self.factory.echoers.remove(self)
    112117
     118
    113119class MultiEchoFactory(Factory):
    114     protocol = MultiEcho
    115120    def __init__(self):
    116121        self.echoers = []
     122
     123    def buildProtocol(self, addr):
     124        return MultiEcho(self)
    117125
    118126reactor.listenTCP(4321, MultiEchoFactory())