moved sendMessage code to chat implementation.