event_publisher.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. // The entry file of your WebAssembly module.
  6. import * as console from "../wamr_app_lib/console"
  7. import * as timer from "../wamr_app_lib/timer"
  8. import * as request from "../wamr_app_lib/request"
  9. function publish_overheat_event(): void {
  10. var payload = String.UTF8.encode("warning: temperature is over high");
  11. request.publish_event("alert/overheat", 0, payload, payload.byteLength);
  12. }
  13. export function on_init() : void {
  14. timer.setInterval(publish_overheat_event, 2000);
  15. }
  16. export function on_destroy() : void {
  17. }
  18. /* Function below are requred by wamr runtime, don't remove or modify them */
  19. export function _on_timer_callback(on_timer_id: i32): void {
  20. timer.on_timer_callback(on_timer_id);
  21. }
  22. export function _on_request(buffer_offset: i32, size: i32): void {
  23. request.on_request(buffer_offset, size);
  24. }
  25. export function _on_response(buffer_offset : i32, size: i32): void {
  26. request.on_response(buffer_offset, size);
  27. }