Well ... you're just right but the code is still closed atm so you have to be happy with some snippets. I left out unimportant functions and replaced names with representatives.
The main.py: import controller controller.controller().startConnection('127.0.0.1',23002) The controller.py: import model, view class controller(): def __init__(self): self.model = model.Client(self) self.view = view.view(self) def startConnection(self,server,port): self.model.startConnection(server,port) def gotConnection(self): print 'connection established' self.model.sendHandshake('some hash') And finaly the model.py: from twisted.internet import reactor, protocol, task, ssl from twisted.protocols import basic class Client(basic.LineOnlyReceiver, protocol.Factory): def __init__(self,controller): """Takes one argument: the instance of the controller Class.""" self.controller=controller def startConnection(self,server,port): """Initiate the connection.""" reactor.connectSSL(server, port, self, ssl.ClientContextFactory()) reactor.run() def buildProtocol(self, addr): return self def connectionMade(self): self.controller.gotConnection() def sendHandshake(self,hash): """The Handshake has to be send first, after a ssl connection is established""" self.sendLine('line to that the server respond with another line') def lineReceived(self,data): self.controller.foo(data) 2008/12/15 Valentino Volonghi <dialt...@gmail.com> > > On Dec 14, 2008, at 9:38 PM, Christian Scharkus wrote: > > methods of the instance and send messages to the server. So how do I > connect > the model to he server? In former implementations I were using the > Clientfactory but this didn't work very well. > > > <mode yoda> > Use the code Luke > </mode yoda> > > Without showing the code it's hard to give an help. Anyway it's the > responsibility of the protocol to translate a line into a controller call, > and the controller should then consider calling something on the > model but again without the code it's pretty hard to guess which is > edge A5 and which is panel G3. :) > > -- > Valentino Volonghi aka Dialtone > Now running MacOS X 10.5 > Home Page: http://www.twisted.it > http://www.adroll.com > > > _______________________________________________ > Twisted-Python mailing list > Twisted-Python@twistedmatrix.com > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python > >
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python