Implements the server logic of the chat application.