Reputation: 91
I wonder how i can add my own callbacks to the asyncio's class Protocol. For example here is my client class:
class EchoClientProtocol(asyncio.Protocol):
def data_received(self, data):
print('Data received: {!r}'.format(data.decode()))
I would like to add this callback:
def hello_received(self):
print("Hello received")
which will be called when "Hello" is received.
Thank you for your help !
Upvotes: 0
Views: 207
Reputation: 17366
You should parse incoming data in data_received()
and after reaching hello may call your own callback like hello_received()
Upvotes: 1