2021-07-20 14:00:26 +03:00
|
|
|
import "@fluencelabs/aqua-lib/builtin.aqua"
|
|
|
|
|
2021-08-04 23:13:47 -05:00
|
|
|
const helloWorldNodePeerId ?= "12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi"
|
|
|
|
const helloWorldServiceId ?= "1e740ce4-81f6-4dd4-9bed-8d86e9c2fa50"
|
2021-07-20 14:00:26 +03:00
|
|
|
|
2021-07-20 17:49:58 +03:00
|
|
|
data HelloResponse:
|
2021-07-20 14:00:26 +03:00
|
|
|
msg: string
|
|
|
|
reply: string
|
|
|
|
|
2021-07-20 17:49:58 +03:00
|
|
|
-- The service runs on a Fluence node
|
|
|
|
service HelloWorld:
|
|
|
|
hello_world(from: PeerId) -> HelloResponse
|
2021-07-20 14:00:26 +03:00
|
|
|
|
2021-07-20 17:49:58 +03:00
|
|
|
-- The service runs inside browser
|
|
|
|
service HelloPeer("HelloPeer"):
|
|
|
|
hello(message: string) -> string
|
2021-07-20 14:00:26 +03:00
|
|
|
|
2021-07-20 17:49:58 +03:00
|
|
|
func sayHello(targetPeerId: PeerId, targetRelayPeerId: PeerId) -> string:
|
|
|
|
-- execute computation on a Peer in the network
|
|
|
|
on helloWorldNodePeerId:
|
|
|
|
HelloWorld helloWorldServiceId
|
|
|
|
comp <- HelloWorld.hello_world(%init_peer_id%)
|
2021-07-20 14:00:26 +03:00
|
|
|
|
2021-07-20 17:49:58 +03:00
|
|
|
-- send the result to target browser in the background
|
|
|
|
co on targetPeerId via targetRelayPeerId:
|
|
|
|
res <- HelloPeer.hello(%init_peer_id%)
|
2021-07-20 14:00:26 +03:00
|
|
|
|
2021-07-20 17:49:58 +03:00
|
|
|
-- send the result to the initiator
|
2021-07-20 14:00:26 +03:00
|
|
|
<- comp.reply
|