I adapted the SnackBot example to send my own messages from an agent generated web page, but when I use the imp.onidle method below the device never receives the agent message. If I comment out the following code then the agent.on method is processed (although the delay from clicking a button to receiving the message can be 30+ seconds).
imp.onidle(function() { do_stuff(); server.sleepfor(20); });
The device probably cannot sleep while listening for agent messages. If that is true how do I do_stuff() on an interval? In the SnackBot example, does the device respond immediately to a button click?