def add_callback(self, callback, msg_type=None):
cb_keys = self._to_iter(msg_type)<EOL>if cb_keys is not None:<EOL><INDENT>for msg_type_ in cb_keys:<EOL><INDENT>self._callbacks[msg_type_].add(callback)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self._callbacks[msg_type].add(callback)<EOL><DEDENT>
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.