Commit a78c1b6c authored by Tiago Cunha's avatar Tiago Cunha

Modified method return

parent 857c8cf2
...@@ -301,7 +301,7 @@ public class MethodCallHelper { ...@@ -301,7 +301,7 @@ public class MethodCallHelper {
/** /**
* send message. * send message.
*/ */
public Task<JSONObject> sendMessage(String messageId, String roomId, String msg) { public Task<Void> sendMessage(String messageId, String roomId, String msg) {
try { try {
return sendMessage(new JSONObject() return sendMessage(new JSONObject()
.put("_id", messageId) .put("_id", messageId)
...@@ -315,19 +315,9 @@ public class MethodCallHelper { ...@@ -315,19 +315,9 @@ public class MethodCallHelper {
/** /**
* Send message object. * Send message object.
*/ */
private Task<JSONObject> sendMessage(final JSONObject messageJson) { private Task<Void> sendMessage(final JSONObject messageJson) {
return call("sendMessage", TIMEOUT_MS, () -> new JSONArray().put(messageJson)) return call("sendMessage", TIMEOUT_MS, () -> new JSONArray().put(messageJson))
.onSuccessTask(task -> { .onSuccessTask(task -> Task.forResult(null));
final String result = task.getResult();
if (result.equals("")) {
// valid success result
return Task.forResult(new JSONObject());
}
// should validate any other response
final JSONObject jsonObject = new JSONObject(result);
return Task.forResult(Message.customizeJson(jsonObject));
});
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment