diff --git a/src/main/java/org/bdware/server/ws/EventActions.java b/src/main/java/org/bdware/server/ws/EventActions.java index 4b4a2a7..b61665d 100644 --- a/src/main/java/org/bdware/server/ws/EventActions.java +++ b/src/main/java/org/bdware/server/ws/EventActions.java @@ -10,8 +10,15 @@ import org.bdware.server.action.CMActions; public class EventActions { @Action(async = true, userPermission = 0) public void subEvent(JsonObject args, final ResultCallback rcb) { + JsonObject ret = new JsonObject(); + ret.addProperty("action", "onSubEvent"); + ret.addProperty("status", "Error"); + if (args.has("requestID")) { + ret.addProperty("responseID", args.get("requestID").getAsString()); + } if (!args.has("topic")) { - rcb.onResult("{\"status\":\"Error\",\"data\":\"no topic arg!\"}"); + ret.addProperty("data", "no topic arg!"); + rcb.onResult(ret.toString()); return; } String topic = args.get("topic").getAsString(); @@ -19,12 +26,16 @@ public class EventActions { String argCID = args.get("contractID").getAsString(); ContractClient client = CMActions.manager.getClient(argCID); if (null == client) { - rcb.onResult("{\"status\":\"Error\",\"data\":\"invalid contract ID or Name!\"}"); + ret.addProperty("data", "invalid contract ID or Name!"); + rcb.onResult(ret.toString()); return; } String contractID = client.getContractID(); topic = HashUtil.sha3(contractID + topic); } CMActions.manager.subEventByClient(topic, rcb.getChannel()); + ret.addProperty("status", "Success"); + ret.addProperty("data", topic); + rcb.onResult(ret.toString()); } }