我正在尝试从Android客户端接收带有套接字的JSON文件。 我试过这个:
socket.on("EVT_ReceptionArtefactMessage", function (artefact) {
console.log(artefact.title)
});
这是android代码
private final static String JSON_PSEUDO = "creator";
private final static String JSON_TITLE = "title";
private final static String JSON_MESSAGE = "message";
public JSONObject toJSON() {
JSONObject object = new JSONObject();
try {
object.putOpt(Artifact.JSON_PSEUDO, this.pseudo);
object.putOpt(Artifact.JSON_TITLE, this.title);
object.putOpt(Artifact.JSON_MESSAGE, this.message);
} catch (JSONException e) {
e.printStackTrace();
}
return object;
}
socket.emit("EVT_ReceptionArtefactMessage",artefact.toJSON());
但它不起作用。你能告诉我这件事有什么意义吗?