feat: add event publishing

add NodeCenterActions.publishEvent
This commit is contained in:
Frank.R.Wu 2022-07-30 16:45:12 +08:00
parent 10de4e0d5f
commit 0fd984d5fd

View File

@ -1649,6 +1649,16 @@ public class NodeCenterActions {
resultCallback.onResult(ret.toString()); resultCallback.onResult(ret.toString());
} }
@Action(async = true)
public void publishEvent(JsonObject args, final ResultCallback rcb) {
try {
args.addProperty("action", "publishEventFromCenter");
nodeInfos.values().iterator().next().connection.controller.sendMsg(JsonUtil.toJson(args));
} catch (Exception e) {
LOGGER.error("publishEvent error! " + e.getMessage());
}
}
public static class ResultCollector extends ResultCallback { public static class ResultCollector extends ResultCallback {
private final ResultCallback committer; private final ResultCallback committer;
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();