text_consumer.py 392 B

12345678910111213141516171819
  1. from dataclasses import dataclass
  2. from abc import ABC, abstractmethod
  3. @dataclass
  4. class Message:
  5. body: str
  6. class TextConsumer(ABC):
  7. @abstractmethod
  8. async def on_message(self, msg: Message):
  9. """
  10. This method is called when a new message is received from the remote peer associated with this TextConsumer.
  11. :param msg: The message
  12. """
  13. pass