code: def decode_rcvd_msg(pref, message, seqnum, pretty=False):
      
      newline = "\n" if pretty else " "
      indent = "    " if pretty else ""
      start = newline + indent
  
      out = []
      out.append("%s%s{%sSEQNUM: %d," % (pref, newline, start, seqnum))
      out.append("%sCLIENTREF: %s," % (start, message[Const.M_CLIENTREF]))
      out.append("%sTYPE: %s," % (start, M_TYPES[message[Const.M_TYPE]]))
      if message[Const.M_TYPE] in M_SUB_TYPES:
          out.append("%sPAYLOAD: {CODE: %s, MESSAGE: %s}" %
                     (start, M_SUB_TYPES[message[Const.M_TYPE]][message[Const.M_PAYLOAD][Const.P_CODE]],
                      message[Const.M_PAYLOAD][Const.P_MESSAGE]))
      else:
          payload = None
          if message[Const.M_PAYLOAD] is not None:
              payload = {}
              for item in message[Const.M_PAYLOAD]:
                  if item == Const.P_RESOURCE:
                      payload['RESOURCE'] = R_TYPES[message[Const.M_PAYLOAD][Const.P_RESOURCE]]
                  else:
                      payload[item] = message[Const.M_PAYLOAD][item]
          out.append("%sPAYLOAD: %s" % (start, payload))
      out.append("%s}" % newline)
  
      return ''.join(out)
docs: decode_rcvd_msg: Return string of received message expanding short codes, optionally with newlines and indent