code: def toDict(self, msg: Dict) -> Dict:
          
  
          if isinstance(msg, Request):
              tmsg = msg.as_dict
          elif hasattr(msg, "_asdict"):
              tmsg = dict(msg._asdict())
          elif hasattr(msg, "__dict__"):
              tmsg = dict(msg.__dict__)
          elif self.allowDictOnly:
              raise ValueError("Message cannot be converted to an appropriate "
                               "format for transmission")
          else:
              tmsg = msg
          return tmsg
docs: Return a dictionary form of the message
  
          :param msg: the message to be sent
          :raises: ValueError if msg cannot be converted to an appropriate format
              for transmission