agent-backend/contracts/EventSubscriber/EventSubscriber.yjs

23 lines
579 B
Plaintext
Raw Permalink Normal View History

2021-09-26 04:49:24 +00:00
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);
}
}