Forgive any newbie errors, as I'm new to Twisted.<br><br>The pattern discussed *seems* to be the same as the 'comet' pattern in web development: a client contacts the server, but rather than responding quickly, the server 'files away' the connection in case there is something to send later. (Filing away, in my case is done by adding a reference to the stream as a member of a 'Connection' class withing my server. 'Connections' can either be 'open' [able to send immediately] or 'buffering' [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 'files it away', rather than calling stream.finish(). 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 'filed away' stream and calls stream.finish(). (In my case, because this is comet, the client immediately makes another connection to the server, which is again 'filed away'.)<br>
<br>I hope this doesn'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> <<a href="mailto:drew.smathers@gmail.com">drew.smathers@gmail.com</a>> 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 <<a href="mailto:dwelch@umail.ucsb.edu">dwelch@umail.ucsb.edu</a>> wrote:<br> > Matt,<br> ><br> > I read that howto/servers documentation and I have set up my code into<br>
> a Factory and Protocol that handles incoming connections.<br> <br> <br>Honestly, I don't think we're dealing with a design pattern issue now.<br> <br><br> > I don't<br> > think I explained myself well enough though. When a client connects,<br>
> the server may or may not being send data back right away so I need to<br> > be able to send data to that connected client on the servers terms.<br> > For example:<br> ><br> > Client 1 connects -- Factory instantiates Protocol class to handle<br>
> communication (connection doesn't close)<br> > Client 2 connects -- Factory instantiates Protocol class to handle<br> > communication (connection doesn't close)<br> > <time has passed until server decides it needs to send a plugin to one<br>
> of the clients><br> > Server sends plugin to Client 1<br> ><br> > So how can that server send data to client 1 if client 1 hasn't caused<br> > an event (The server side causes a certain event it should send data<br>
> to a selected client).<br> <br> <br>Define `event'. Is the initial connection not an event? If you have<br> an open connection, the client doesn'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> > I understand that if a client sends data to the<br> > server I can than write back to the client using the dataReceived<br> > function within the Protocol instantiation.<br> <br> <br>
Are you sure you understand? You're calling dataReceive to send data?<br> If you're calling a method (that's what you meant by "function within<br> the Protocol instantiation", I guess) with "receive" in the name, then<br>
you can only be very confused.<br> <br><br> > In this case once N number<br> > of agents have connected I want the server to push data to the clients<br> > without the Client writing to the server. Thanks again for the help.<br>
><br> <br> <br>So write back data to the client. That's all I can say until you<br> describe what you'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't even attempted.<br> <br> <br> --<br> \\\\\/\"/\\\\\\\\\\\<br> \\\\/ // //\/\\\\\\\<br> \\\/ \\// /\ \/\\\\<br> \\/ /\/ / /\/ /\ \\\<br> \/ / /\/ /\ /\\\ \\<br> / /\\\ /\\\ \\\\\/\<br> \/\\\\\/\\\\\/\\\\\\<br>
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>