parse and validate messages, emit events