Split onMessage into onCommand and onMessage.