Forgive any newbie errors, as I&#39;m new to Twisted.<br><br>The pattern discussed *seems* to be the same as the &#39;comet&#39; pattern in web development: a client contacts the server, but rather than responding quickly, the server &#39;files away&#39; the connection in case there is something to send later.&nbsp; (Filing away, in my case is done by adding a reference to the stream as a member of a &#39;Connection&#39; class withing my server.&nbsp; &#39;Connections&#39; can either be &#39;open&#39; [able to send immediately] or &#39;buffering&#39; [waiting for the client to reconnect].)<br>
<br>I have implemented this pattern using twisted.web2 as follows:<br><br>A render method creates a stream, but &#39;files it away&#39;, rather than calling stream.finish().&nbsp; The render method *does* complete and return, but the connection is thereby held open and no data is immediately sent.<br>
<br>Sometime later, or perhaps never, something happens on the server which causes it to send data on the previously &#39;filed away&#39; stream and calls stream.finish().&nbsp; (In my case, because this is comet, the client immediately makes another connection to the server, which is again &#39;filed away&#39;.)<br>
<br>I hope this doesn&#39;t muddy the issue.<br><br>Regards,<br><br>Chris,<br><br>P.S. I have heard of Nevow Athena, but I wanted something very simple.<br><br><div><span class="gmail_quote">On 05/03/2008, <b class="gmail_sendername">Drew Smathers</b> &lt;<a href="mailto:drew.smathers@gmail.com">drew.smathers@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Tue, Mar 4, 2008 at 11:42 PM, David Welch &lt;<a href="mailto:dwelch@umail.ucsb.edu">dwelch@umail.ucsb.edu</a>&gt; wrote:<br> &gt; Matt,<br> &gt;<br> &gt;&nbsp;&nbsp;I read that howto/servers documentation and I have set up my code into<br>
 &gt;&nbsp;&nbsp;a Factory and Protocol that handles incoming connections.<br> <br> <br>Honestly, I don&#39;t think we&#39;re dealing with a design pattern issue now.<br> <br><br> &gt; I don&#39;t<br> &gt;&nbsp;&nbsp;think I explained myself well enough though. When a client connects,<br>
 &gt;&nbsp;&nbsp;the server may or may not being send data back right away so I need to<br> &gt;&nbsp;&nbsp;be able to send data to that connected client on the servers terms.<br> &gt;&nbsp;&nbsp;For example:<br> &gt;<br> &gt;&nbsp;&nbsp;Client 1 connects -- Factory instantiates Protocol class to handle<br>
 &gt;&nbsp;&nbsp;communication (connection doesn&#39;t close)<br> &gt;&nbsp;&nbsp;Client 2 connects -- Factory instantiates Protocol class to handle<br> &gt;&nbsp;&nbsp;communication (connection doesn&#39;t close)<br> &gt;&nbsp;&nbsp;&lt;time has passed until server decides it needs to send a plugin to one<br>
 &gt;&nbsp;&nbsp;of the clients&gt;<br> &gt;&nbsp;&nbsp;Server sends plugin to Client 1<br> &gt;<br> &gt;&nbsp;&nbsp;So how can that server send data to client 1 if client 1 hasn&#39;t caused<br> &gt;&nbsp;&nbsp;an event (The server side causes a certain event it should send data<br>
 &gt;&nbsp;&nbsp;to a selected client).<br> <br> <br>Define `event&#39;.&nbsp;&nbsp;Is the initial connection not an event?&nbsp;&nbsp;If you have<br> an open connection, the client doesn&#39;t have fart back through it every<br> 5 seconds (by the semantics of most protocols) to keep it open or<br>
 anything.<br> <br><br> &gt;&nbsp;&nbsp;I understand that if a client sends data to the<br> &gt;&nbsp;&nbsp;server I can than write back to the client using the dataReceived<br> &gt;&nbsp;&nbsp;function within the Protocol instantiation.<br> <br> <br>
Are you sure you understand?&nbsp;&nbsp;You&#39;re calling dataReceive to send data?<br>&nbsp;&nbsp;If you&#39;re calling a method (that&#39;s what you meant by &quot;function within<br> the Protocol instantiation&quot;, I guess) with &quot;receive&quot; in the name, then<br>
 you can only be very confused.<br> <br><br> &gt; In this case once N number<br> &gt;&nbsp;&nbsp;of agents have connected I want the server to push data to the clients<br> &gt;&nbsp;&nbsp;without the Client writing to the server. Thanks again for the help.<br>
 &gt;<br> <br> <br>So write back data to the client.&nbsp;&nbsp;That&#39;s all I can say until you<br> describe what you&#39;ve tried (w/ code) and why it failed (w/ a<br> stacktrace) - vs. in pretty vague terms on essay on what you want to<br>
 do and haven&#39;t even attempted.<br> <br> <br> --<br> \\\\\/\&quot;/\\\\\\\\\\\<br> \\\\/ // //\/\\\\\\\<br> \\\/&nbsp;&nbsp;\\// /\ \/\\\\<br> \\/ /\/ / /\/ /\ \\\<br> \/ / /\/ /\&nbsp;&nbsp;/\\\ \\<br> / /\\\&nbsp;&nbsp;/\\\ \\\\\/\<br> \/\\\\\/\\\\\/\\\\\\<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d.p.s<br> <br><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">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
 </blockquote></div><br>