feat: update event subscriber

update test case for EventSubscriberClient
This commit is contained in:
Frank.R.Wu 2021-11-01 14:18:30 +08:00
parent 4ef2d7a74b
commit 07627ca2d7
2 changed files with 18 additions and 18 deletions

View File

@ -46,23 +46,23 @@ public class EventSubscriberClient implements Handler {
e.printStackTrace();
}
}
Map<String, String> setNodeID = new HashMap<>();
setNodeID.put("action", "setNodeID");
SM2KeyPair keyPair = SM2Util.generateSM2KeyPair(null);
setNodeID.put("id", keyPair.getPublicKeyStr());
byte[] sig;
try {
sig =
SM2Util.sign(
keyPair.getPrivateKeyParameter(), keyPair.getPublicKeyStr().getBytes());
setNodeID.put("signature", ByteUtils.toHexString(sig));
} catch (CryptoException e) {
e.printStackTrace();
}
setNodeID.put("nodeName", "[LiteClient_" + System.currentTimeMillis() + "]");
bc.sendText(new Gson().toJson(setNodeID));
// Map<String, String> setNodeID = new HashMap<>();
// setNodeID.put("action", "setNodeID");
// SM2KeyPair keyPair = SM2Util.generateSM2KeyPair(null);
// setNodeID.put("id", keyPair.getPublicKeyStr());
//
// byte[] sig;
// try {
// sig =
// SM2Util.sign(
// keyPair.getPrivateKeyParameter(), keyPair.getPublicKeyStr().getBytes());
// setNodeID.put("signature", ByteUtils.toHexString(sig));
//
// } catch (CryptoException e) {
// e.printStackTrace();
// }
// setNodeID.put("nodeName", "[LiteClient_" + System.currentTimeMillis() + "]");
// bc.sendText(new Gson().toJson(setNodeID));
}
public void subscribeEvent(String contractID, String topic) {

View File

@ -6,7 +6,7 @@ import java.util.Scanner;
public class EventClientTest {
public static EventSubscriberClient getTestClient() {
return new EventSubscriberClient("ws://162.105.175.243:1718/SCIDE/NodeCenter");
return new EventSubscriberClient("ws://localhost:8080/SCIDE/SCExecutor");
}
public static void main(String[] args) {