12345678910111213141516171819202122232425262728293031323334 |
- /*
- * mycoagent.c
- *
- * This is an example agent that showcases the use of mycorrhiza.
- */
- #include "../src/myco-agent.c"
- int main() {
- char *agent_name = "DOMAIN1_MYAGENT2";
- int agent_message_queue_id = myco_agent_register(agent_name);
- // View available resources
- myco_agent_request_resource_list(agent_message_queue_id);
- // MYCO fetch
- // #MYCO fetch("RESOURCE_1")
- char *resource_name = "RESOURCE_1";
- struct resource myresource1;
- myresource1 = myco_agent_request_resource(agent_message_queue_id, agent_name, "RESOURCE_1");
- if (myresource1.size != -1) {
- printf("The first integer of RESOURCE_1 is: %d\n", *((int*)myresource1.pointer));
- }
- // MYCO free
- // #MYCO free("RESOURCE_1")
- myco_agent_unregister_resource(agent_message_queue_id, resource_name);
- // At the end of its runtime the agent unregisters with the daemon.
- myco_agent_unregister(agent_name, agent_message_queue_id);
- return EXIT_SUCCESS;
- }
|