add chat connection logic to client side