made SocketClient javascript for following disign pattern