[Twisted-Python] Twisted lineReceived (sender)
lee.a.connell at gmail.com
Fri Jan 12 21:24:41 MST 2007
I just started with twisted and want to write a simple chat server. This
code here works fine, however I want to know who the data is coming from in
the callbacks or events. You can see where I commented code out in def
lineReceived as to what I want to do. How can this be done in the easiest
from twisted.protocols import basic
print "Got new client!"
def connectionLost(self, reason):
print "Lost a client!"
def lineReceived(self, line):
print "received", repr(line)
for c in self.factory.clients:
#if c != sender:
def message(self, message):
if message != '':
self.transport.write(message + '\n')
from twisted.internet import protocol
from twisted.application import service, internet
factory = protocol.ServerFactory()
factory.protocol = MyChat
factory.clients = 
application = service.Application("chatserver")
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.16.10/624 - Release Date: 1/12/2007
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-Python