mirror of
https://gitee.com/BDWare/agent-backend
synced 2025-01-10 09:54:11 +00:00
23 lines
579 B
Plaintext
23 lines
579 B
Plaintext
|
contract EventSubscriber {
|
||
|
function onCreate() {
|
||
|
Global.message = '';
|
||
|
Global.events = [];
|
||
|
}
|
||
|
export function init(topic) {
|
||
|
print(topic);
|
||
|
YancloudUtil.subscribe(topic, handler);
|
||
|
return 'done';
|
||
|
}
|
||
|
function handler(e) {
|
||
|
var ret = 'receive event, topic: ' + e.topic + ' semantics: ' + e.semantics +
|
||
|
' content:\n' + JSON.stringify(e.content);
|
||
|
Global.message = ret;
|
||
|
Global.events.push(e.getAll());
|
||
|
}
|
||
|
export function getMsg() {
|
||
|
return Global.message;
|
||
|
}
|
||
|
export function getEves() {
|
||
|
return JSON.stringify(Global.events);
|
||
|
}
|
||
|
}
|