Reputation: 8322
I've recently been learning twisted, so I can integrate the framework into a pygames script. I've found there are alot of examples and tutorials that override the existing methods in twisted(please correct me if I'm mistaken).
In this simple client I have the twisted.protocols.basic.LineReceiver.lineReceived
method being overriden when ever a line is sent
class ChatClientProtocol(LineReceiver):
def lineReceived(self,line):
print (line)
class ChatClient(ClientFactory):
def __init__(self):
self.protocol = ChatClientProtocol
reactor.connectTCP('192.168.1.2', 6000, ChatClient())
reactor.run()
Is the LineReceiver.lineReceived
a listening socket at the address sent to the reactor.connctTCP
? Would there be a way to do this without overriding the method? Or is this the paradigm of twisted(overriding is the way use twisted)?
Upvotes: 1
Views: 127
Reputation: 31900
LineReceiver.lineReceived
is a method that gets called when a line is received. I don't know what you mean by asking if it's a "listening socket".
Overriding is the way that you receive lines using LineReceiver
. Generally speaking, overriding or implementing callbacks for specific notifications is how you get called in Twisted, yes. How else would you want to do it?
Upvotes: 1