Added main message-processing function processMessage().