We’re using Openvidu 2.20.0 and this is only an issue when we join the call from an Android app, the issue doesn’t exist between openvidu-browser users.
The android code that we’re using was initially based on the openvidu Android demo repo.
To the problem:
From the Android app we want to send the streamPropertyChanged event, changing the audioActive property.
This is the code that puts the parameters together.
Map<String, String> params = new HashMap<>();
params.put("property", "audioActive");
params.put("streamId", streamId);
params.put("newValue", "true");
params.put("reason", "publishAudio");
this.ID_PUBLISHAUDIO.set(this.sendJson(JsonConstants.STREAMPROPERTYCHANGED_METHOD, params));
This event is recieved by other participants but it comes out like this in the websocket message:
{"method":"streamPropertyChanged","params":{"connectionId":"con_LO2S0hU7Gl","streamId":"str_CAM_LUck_con_LO2S0hU7Gl","property":"audioActive","newValue":"\"true\"","reason":"publishAudio"},"jsonrpc":"2.0"}
Please take note of the “newValue” value. This is how the browser user get the event - it is escaped and interpreted as false.
Is this something that you’ve seen before? I can’t find anything wrong in the app and no errors in the server logs.
Feels like this is an issue with how it’s sent via the Android app.
The sendJson method looks like this:
public synchronized int sendJson(String method, Map<String, String> params) {
final int id = RPC_ID.get();
JSONObject jsonObject = new JSONObject();
try {
JSONObject paramsJson = new JSONObject();
for (Map.Entry<String, String> param : params.entrySet()) {
paramsJson.put(param.getKey(), param.getValue());
}
jsonObject.put("jsonrpc", JsonConstants.JSON_RPCVERSION);
jsonObject.put("method", method);
jsonObject.put("id", id);
jsonObject.put("params", paramsJson);
} catch (JSONException e) {
Log.e(TAG, "JSONException raised on sendJson", e);
return -1;
}
this.websocket.sendText(jsonObject.toString());
RPC_ID.incrementAndGet();
return id;
}
Just can’t find an issue with how the text is sent over the websocket.