mirror of
https://github.com/fluencelabs/examples
synced 2025-04-24 18:22:15 +00:00
29 lines
917 B
Plaintext
29 lines
917 B
Plaintext
import "@fluencelabs/aqua-lib/builtin.aqua"
|
|
|
|
const HELLO_WORLD_NODE_PEER_ID ?= "12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi"
|
|
const HELLO_WORLD_SERVICE_ID ?= "1e740ce4-81f6-4dd4-9bed-8d86e9c2fa50"
|
|
|
|
data HelloWorld:
|
|
msg: string
|
|
reply: string
|
|
|
|
-- The service runs on a Fluence node
|
|
service HelloWorld:
|
|
hello(from: PeerId) -> HelloWorld
|
|
|
|
-- The service runs inside browser
|
|
service HelloPeer("HelloPeer"):
|
|
hello(message: string) -> string
|
|
|
|
func sayHello(targetPeerId: PeerId, targetRelayPeerId: PeerId) -> string:
|
|
-- execute computation on a Peer in the network
|
|
on HELLO_WORLD_NODE_PEER_ID:
|
|
HelloWorld HELLO_WORLD_SERVICE_ID
|
|
comp <- HelloWorld.hello(%init_peer_id%)
|
|
|
|
-- send the result to target browser in the background
|
|
co on targetPeerId via targetRelayPeerId:
|
|
res <- HelloPeer.hello(%init_peer_id%)
|
|
|
|
-- send the result to the initiator
|
|
<- comp.reply |