diff options
Diffstat (limited to 'fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/assembly-script/samples/event_publisher.ts')
-rw-r--r-- | fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/assembly-script/samples/event_publisher.ts | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/assembly-script/samples/event_publisher.ts b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/assembly-script/samples/event_publisher.ts new file mode 100644 index 00000000..3ca133fd --- /dev/null +++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/assembly-script/samples/event_publisher.ts @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +// The entry file of your WebAssembly module. +import * as console from "../wamr_app_lib/console" +import * as timer from "../wamr_app_lib/timer" +import * as request from "../wamr_app_lib/request" + +function publish_overheat_event(): void { + var payload = String.UTF8.encode("warning: temperature is over high"); + request.publish_event("alert/overheat", 0, payload, payload.byteLength); +} + +export function on_init() : void { + timer.setInterval(publish_overheat_event, 2000); +} + +export function on_destroy() : void { + +} + + +/* Function below are requred by wamr runtime, don't remove or modify them */ +export function _on_timer_callback(on_timer_id: i32): void { + timer.on_timer_callback(on_timer_id); +} + +export function _on_request(buffer_offset: i32, size: i32): void { + request.on_request(buffer_offset, size); +} + +export function _on_response(buffer_offset : i32, size: i32): void { + request.on_response(buffer_offset, size); +}
\ No newline at end of file |