Well ... you&#39;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(&#39;127.0.0.1&#39;,23002)<br><br>The controller.py:<br><br>import model, view<br><br>class controller():<br>&nbsp;&nbsp;&nbsp; def __init__(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.model = model.Client(self)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.view = view.view(self)<br><br>&nbsp;&nbsp;&nbsp; def startConnection(self,server,port):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.model.startConnection(server,port)<br><br>&nbsp;&nbsp;&nbsp; def gotConnection(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &#39;connection established&#39;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.model.sendHandshake(&#39;some hash&#39;)<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>&nbsp;&nbsp;&nbsp; def __init__(self,controller):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;Takes one argument: the instance of the controller Class.&quot;&quot;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.controller=controller<br><br>&nbsp;&nbsp;&nbsp; def startConnection(self,server,port):<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;Initiate the connection.&quot;&quot;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reactor.connectSSL(server, port, self, ssl.ClientContextFactory())<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reactor.run()<br><br>&nbsp;&nbsp;&nbsp; def buildProtocol(self, addr):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return self<br>
<br>&nbsp;&nbsp;&nbsp; def connectionMade(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.controller.gotConnection()<br><br>&nbsp;&nbsp;&nbsp; def sendHandshake(self,hash):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;The Handshake has to be send first, after a ssl connection is established&quot;&quot;&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.sendLine(&#39;line to that the server respond with another line&#39;)<br><br>&nbsp;&nbsp;&nbsp; def lineReceived(self,data):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.controller.foo(data)<br><br><div class="gmail_quote">2008/12/15 Valentino Volonghi <span dir="ltr">&lt;<a href="mailto:dialtone@gmail.com">dialtone@gmail.com</a>&gt;</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&#39;t work very well.<br>
</div></blockquote></div><div><br></div></div><div>&lt;mode yoda&gt;</div><div>Use the code Luke</div><div>&lt;/mode yoda&gt;</div><div><br></div><div>Without showing the code it&#39;s hard to give an help. Anyway it&#39;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&#39;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&nbsp;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>