code: def add_callback(self, callback, msg_type=None):
          
          cb_keys = self._to_iter(msg_type)
          if cb_keys is not None:
              for msg_type_ in cb_keys:
                  self._callbacks[msg_type_].add(callback)
          else:
              self._callbacks[msg_type].add(callback)
docs: Add per message type or global callback.
  
          Parameters
          ----------
          callback : fn
            Callback function
          msg_type : int | iterable
            Message type to register callback against. Default `None` means global callback.
            Iterable type adds the callback to all the message types.