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.<br><br>The main.py:<br><br>import controller<br>
<br>controller.controller().startConnection('127.0.0.1',23002)<br><br>The controller.py:<br><br>import model, view<br><br>class controller():<br> def __init__(self):<br> self.model = model.Client(self)<br>
self.view = view.view(self)<br><br> def startConnection(self,server,port):<br> self.model.startConnection(server,port)<br><br> def gotConnection(self):<br> print 'connection established'<br>
self.model.sendHandshake('some hash')<br><br>And finaly the model.py:<br><br>from twisted.internet import reactor, protocol, task, ssl<br>from twisted.protocols import basic<br><br>class Client(basic.LineOnlyReceiver, protocol.Factory):<br>
<br> def __init__(self,controller):<br> """Takes one argument: the instance of the controller Class."""<br> self.controller=controller<br><br> def startConnection(self,server,port):<br>
"""Initiate the connection."""<br> reactor.connectSSL(server, port, self, ssl.ClientContextFactory())<br> reactor.run()<br><br> def buildProtocol(self, addr):<br> return self<br>
<br> def connectionMade(self):<br> self.controller.gotConnection()<br><br> def sendHandshake(self,hash):<br> """The Handshake has to be send first, after a ssl connection is established"""<br>
self.sendLine('line to that the server respond with another line')<br><br> def lineReceived(self,data):<br> self.controller.foo(data)<br><br><div class="gmail_quote">2008/12/15 Valentino Volonghi <span dir="ltr"><<a href="mailto:dialtone@gmail.com">dialtone@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div style=""><div class="Ih2E3d"><br><div><div>On Dec 14, 2008, at 9:38 PM, Christian Scharkus wrote:</div>
<div><br></div><blockquote type="cite"><div>methods of the instance and send messages to the server. So how do I connect<br>the model to he server? In former implementations I were using the<br>Clientfactory but this didn't work very well.<br>
</div></blockquote></div><div><br></div></div><div><mode yoda></div><div>Use the code Luke</div><div></mode yoda></div><div><br></div><div>Without showing the code it's hard to give an help. Anyway it's the</div>
<div>responsibility of the protocol to translate a line into a controller call,</div><div>and the controller should then consider calling something on the</div><div>model but again without the code it's pretty hard to guess which is</div>
<div>edge A5 and which is panel G3. :)</div><br><font color="#888888"><div> <span style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div style="">
<span style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div style="">
<span style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div style="">
<div><div><span style="border-collapse: collapse; font-family: arial; font-size: 13px; white-space: pre-wrap;">-- </span></div><div><span style="border-collapse: collapse; font-family: arial; font-size: 13px; white-space: pre-wrap;">Valentino Volonghi aka Dialtone</span></div>
<div><span style="border-collapse: collapse; font-family: arial; font-size: 13px; white-space: pre-wrap;">Now running MacOS X 10.5</span></div><div><span style="border-collapse: collapse; font-family: arial; font-size: 13px; white-space: pre-wrap;">Home Page: <a href="http://www.twisted.it" target="_blank">http://www.twisted.it</a> </span></div>
<div><span style="border-collapse: collapse; font-family: arial; font-size: 13px; white-space: pre-wrap;"><a href="http://www.adroll.com" target="_blank">http://www.adroll.com</a></span></div></div></div></span></div></span></div>
</span> </div><br></font></div><br>_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
<br></blockquote></div><br>