Implements the client logic of the chat application.