Message does not arrive in the proper format on the server - Socket.io

Viewed 16

I'm rewriting an app in react-native for android native and I need to rewrite the client socket that sends a message to the server notifying that it has connected the call room.

The connection goes well and the message is sent to the server, however the format that the message arrives is inappropriate for it to be read and I am not able to do it in java in the same way as it is done in react.

How to convert this code to java?

sendFamiliarJoined = (patientId: any, familiarId: any) => {
 if (this.socket) {
  this.socket.emit("message", {
    id: 'familiarEnteredInRoom',
    patientId,
    familiarId,
  });
  }
 }

Currently in java I'm doing it like the code below but the message still doesn't arrive in the desired format

JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("id","familiarEnteredInRoom");
jsonObject.addProperty("patientId", patientRepo.getPatientId());
jsonObject.addProperty("familiarId", userRepo.getUSerId());

mSocket.emit("message", "id : familiarLeftRoom", jsonObject);

The desired format would be something like:

desired format

0 Answers
Related