update after publish. json is used for sending and receiving msg

code updated after geting request type in server.