myconetwork.c 870 B

1234567891011121314151617181920212223242526272829
  1. /*
  2. * mycoagent.c
  3. *
  4. * This is an example agent that showcases the use of mycorrhiza.
  5. */
  6. #include "../src/myco-agent.c"
  7. int main() {
  8. char *agent_name = "DOMAIN1_MYAGENT";
  9. int agent_message_queue_id = myco_agent_register(agent_name);
  10. // MYCO create
  11. // #MYCO create("RESOURCE_1", 1024, transactional)
  12. char *resource_name = "RESOURCE_1";
  13. int resource_size = 1024;
  14. void *resource_pointer = myco_agent_register_resource(agent_message_queue_id, agent_name, resource_name, RESOURCE_TRANSACTIONAL, getpid(), resource_size);
  15. // View available resources
  16. myco_agent_request_resource_list(agent_message_queue_id);
  17. printf("Sleeping for 30 seconds...\n");
  18. sleep(30);
  19. // At the end of its runtime the agent unregisters with the daemon.
  20. myco_agent_unregister(agent_name, agent_message_queue_id);
  21. return EXIT_SUCCESS;
  22. }