Change EncodeMessages function to include username.

Avoid connecting server twice for display message info on UI.