implemented duplex json communication.