[Twisted-Python] LineReceiver

Lee Connell lee.a.connell at gmail.com
Sun Feb 25 16:26:33 MST 2007


Hello all,

I am building a basic chat program.  I am using LineReceiver for the
protocol on both the server and the client.  My problem is when i loop
through all the clients in my ServerFactory and choose to send data to the
client with multiple calls to transport.write(data), the client side does
not pick it up in two seperate calls, instead it is received in one
lineReceive. In the server I call transport.write() twice, the client
however receives both calls in one lineReceive instead of two lineRecieve
calls, how can I get lineReceive to be fired for each transported message?

//// CLIENT LINE RECEIVE ////

    def lineReceived(self, line):
        if self.app:
            self.app.addMessage(line)

//// SERVER CONNECTION MADE ////

    def connectionMade(self):
        self.factory.clients.append(self)
        host = self.transport.getPeer().host + ": joined the server."

        for c in self.factory.clients:
            c.transport.write(host + '\n')
            if self == c:
                c.transport.write(self.getMOTD())   ### getMOTD just returns
some string ###
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20070225/b211bbc3/attachment.htm 


More information about the Twisted-Python mailing list