mirror of
https://gitee.com/BDWare/cp.git
synced 2025-01-10 01:44:08 +00:00
feat: add return value of JavaScriptEntry.subscribe
This commit is contained in:
parent
47ed2656dd
commit
18f40dc6a9
@ -586,12 +586,13 @@ public class JavaScriptEntry {
|
|||||||
* @param fun related handler function
|
* @param fun related handler function
|
||||||
* @author Kaidong Wu
|
* @author Kaidong Wu
|
||||||
*/
|
*/
|
||||||
public static void subscribe(String topic, ScriptFunction fun) {
|
public static String subscribe(String topic, ScriptFunction fun) {
|
||||||
subscribe(topic, fun, false);
|
subscribe(topic, fun, false);
|
||||||
if (topic_handlers.containsKey(topic)) {
|
if (topic_handlers.containsKey(topic)) {
|
||||||
ContractProcess.instance.unSubscribe(topic_handlers.get(topic).getName());
|
ContractProcess.instance.unSubscribe(topic_handlers.get(topic).getName());
|
||||||
}
|
}
|
||||||
topic_handlers.put(topic, fun);
|
topic_handlers.put(topic, fun);
|
||||||
|
return topic;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -602,13 +603,14 @@ public class JavaScriptEntry {
|
|||||||
* @param fun related handler function
|
* @param fun related handler function
|
||||||
* @author Kaidong Wu
|
* @author Kaidong Wu
|
||||||
*/
|
*/
|
||||||
public static void subscribe(String contractID, String event, ScriptFunction fun) {
|
public static String subscribe(String contractID, String event, ScriptFunction fun) {
|
||||||
String topic = HashUtil.sha3(contractID, event);
|
String topic = HashUtil.sha3(contractID, event);
|
||||||
subscribe(topic, fun, false);
|
subscribe(topic, fun, false);
|
||||||
if (topic_handlers.containsKey(topic)) {
|
if (topic_handlers.containsKey(topic)) {
|
||||||
ContractProcess.instance.unSubscribe(topic_handlers.get(topic).getName());
|
ContractProcess.instance.unSubscribe(topic_handlers.get(topic).getName());
|
||||||
}
|
}
|
||||||
topic_handlers.put(topic, fun);
|
topic_handlers.put(topic, fun);
|
||||||
|
return topic;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void subscribe(String topic, ScriptFunction fun, boolean fromPreSub) {
|
private static void subscribe(String topic, ScriptFunction fun, boolean fromPreSub) {
|
||||||
|
Loading…
Reference in New Issue
Block a user