feat: update event subscriber

update EventSubscriberClient.subscribeEvent to use event mechanism
This commit is contained in:
Frank.R.Wu 2021-10-31 23:17:00 +08:00
parent dc5ee173f6
commit 4ef2d7a74b
2 changed files with 3 additions and 5 deletions

View File

@ -65,12 +65,11 @@ public class EventSubscriberClient implements Handler {
bc.sendText(new Gson().toJson(setNodeID)); bc.sendText(new Gson().toJson(setNodeID));
} }
public void subscribeEvent(String nodeID, String contractID, String event) { public void subscribeEvent(String contractID, String topic) {
Map<String, String> msg = new HashMap<>(); Map<String, String> msg = new HashMap<>();
msg.put("action", "subEvent"); msg.put("action", "subEvent");
msg.put("target", nodeID);
msg.put("contractID", contractID); msg.put("contractID", contractID);
msg.put("event", event); msg.put("topic", topic);
bc.sendText(new Gson().toJson(msg)); bc.sendText(new Gson().toJson(msg));
} }
} }

View File

@ -16,7 +16,6 @@ public class EventClientTest {
testClient.waitForConnect(); testClient.waitForConnect();
testClient.subscribeEvent( testClient.subscribeEvent(
"04889daf457aae33f382d3d7688f154a1ffdd057b660e626314f46fd6864c3162bf941b25abe98dd9d7df4d44e31570a15166883271b0c901931db82f714aeeebf",
"BDCoinAt162", "BDCoinAt162",
"Transfer"); "Transfer");
try { try {
@ -25,7 +24,7 @@ public class EventClientTest {
e.printStackTrace(); e.printStackTrace();
} }
Scanner sc = new Scanner(System.in); Scanner sc = new Scanner(System.in);
for (; ; ) { while (true) {
String cmd = sc.nextLine(); String cmd = sc.nextLine();
System.out.println("Wait for event"); System.out.println("Wait for event");
} }