0

I need to write java socket emit code for the following javascript code.

 socket.emit('pageload', { "inputtoken": $('#wtokens').val() });

Java equivalent tried, does not works.

productSocket.emit("pageload","inputtoken : 11721");

Tried different options, but it does not return any event from the server socket.

3
  • The equivalent would be to send a dictionary, wouldn't it? { inputtoken : 11721 }
    – Blindy
    Commented Apr 18, 2023 at 18:55
  • yes, you are correct. dictionary or may be a JSON string. I will give it a try in some time. Commented Apr 19, 2023 at 2:01
  • it is a dictionary, javascript is magical !! Commented Apr 19, 2023 at 8:43

1 Answer 1

0

blindy The following code worked, thanks

     Map<String, String>
                     map = Collections
                     .singletonMap("inputtoken", "11721");

   productSocket.emit("pageload",map);

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.