<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def on(self, message, namespace=None):
 """Decorator to register a SocketIO event handler. This decorator must be applied to SocketIO event handlers. Example:: @socketio.on('my event', namespace='/chat') def handle_my_custom_event(json):
 print('received json: ' + str(json)) :param message: The name of the event. This is normally a user defined string, but a few event names are already defined. Use ``'message'`` to define a handler that takes a string payload, ``'json'`` to define a handler that takes a JSON blob payload, ``'connect'`` or ``'disconnect'`` to create handlers for connection and disconnection events. :param namespace: The namespace on which the handler is to be registered. Defaults to the global namespace. """

        namespace = namespace or '/'

        def decorator(handler):
            def _handler(sid, *args):
                return self._handle_event(handler, message, namespace, sid,
                                          *args)

            if self.server:
                self.server.on(message, _handler, namespace=namespace)
            else:
                self.handlers.append((message, _handler, namespace))
            return handler
        return decorator