Add chat states support
Fix composing chat state
Emit chat and groupchat events, based on message type.