[Twisted-Python] protocol factory
aerodew
ssgzhantr at gmail.com
Thu May 4 21:13:59 MDT 2006
i think Factory is not to the point,just concerned with its
concept,factory
should only take care of producing proper protocol instance.i can't see any
clue
of protocol context in the defintion of factory.so the boudary of factory is
loom,i don't
like it.or on other hand,we can it can be categoried into abstract
factroy,then i proprose
following refraction.
class ProtoAbsFactory:
implements(interfaces.IProtocolFactory)
protocol=None
context=None
numProtos=0
def buildProtocol(self):
pass
def buildContext(self):
pass
class ProtoContext:
def doStart(self):
pass
def doStop(self):
pass
class ClientProtoContext(ProtoContext):
def startedCnnecting(self):
pass
def clientConnectionFailed(self):
pass
def clientConnectionLost(self):
pass
class ReconnectingClientProtoContext(ClientProtoContext):
def clientConnectoionFailed(self,connector,reason):
self.connector=connector
self.retry()
def clientConnectionLost(self,connector,reason):
self.connector=connector
self.retry()
def retry(self):
self.connector.connect()
by introducing context,we make solution for some situation
very simple,just like http,since it is a stateless ,we have to bring
in session to store state information during the communication,here by
refining the context ,we can easily achieve it
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20060505/9ecef08e/attachment.html>
More information about the Twisted-Python
mailing list