permaweb / aos

An operating system for AO: The hyper parallel computer
https://ao.g8way.io
Other
68 stars 46 forks source link

Creating a Pingpong Process in aos-2.0.0 #333

Closed xgocn closed 1 week ago

xgocn commented 2 weeks ago

I created a process follow the cookbook https://cookbook_ao.g8way.io/guides/aos/pingpong.html while it is correct in aos-0.2.1

I got the error

ao-pets@aos-2.0.0[Inbox:1]> Send({ Target = ao.id, Data = "ping" })
{
   onReply = function: 0x2bb2c60,
   output = "Message added to outbox",
   receive = function: 0x2bb2d80
}
Error handling message
[string "aos"]:1039: [string "aos"]:733: attempt to call a nil value (field 'reply')

stack traceback:
        [string ".process"]:535: in field 'handle'
twilson63 commented 2 weeks ago

Yep, the cookbook is currently using aos 2 features:

You can try with the preview version of aos - npm i -g https://preview_ao.arweave.net - and the cookbook example should work.

Or you can use an older pattern:

Handlers.add("pingpong", Handlers.utils.hasMatchingData('ping'), Handers.utils.reply('pong'))

We are trying to get aos 2 out as release as soon as possible.

thx

xgocn commented 2 weeks ago

got it,thx