/* Exposed concatinate method */ void cat_method(alljoyn_busobject bus, const alljoyn_interfacedescription_member* member, alljoyn_message msg) { QStatus status; alljoyn_msgarg outArg; char* str1; char* str2; /* Concatenate the two input strings and reply with the result. */ char result[256] = { 0 }; QCC_UNUSED(member); status = alljoyn_msgarg_get(alljoyn_message_getarg(msg, 0), "s", &str1); if (ER_OK != status) { printf("Ping: Error reading alljoyn_message\n"); } status = alljoyn_msgarg_get(alljoyn_message_getarg(msg, 1), "s", &str2); if (ER_OK != status) { printf("Ping: Error reading alljoyn_message\n"); } snprintf(result, sizeof(result), "%s%s", str1, str2); outArg = alljoyn_msgarg_create_and_set("s", result); status = alljoyn_busobject_methodreply_args(bus, msg, outArg, 1); if (ER_OK != status) { printf("Ping: Error sending reply\n"); } alljoyn_msgarg_destroy(outArg); }
void AJ_CALL delayed_ping(alljoyn_busobject busobject, const alljoyn_interfacedescription_member* member, alljoyn_message msg) { QStatus status = ER_OK; char*value = NULL; alljoyn_msgarg outArg; uint32_t delay = 0; /* Enable concurrent callbacks since some of the calls below could block */ alljoyn_busattachment_enableconcurrentcallbacks(g_msgBus); status = alljoyn_msgarg_get(alljoyn_message_getarg(msg, 0), "s", &value); status = alljoyn_msgarg_get(alljoyn_message_getarg(msg, 1), "u", &delay); printf("Pinged (response delayed %ums) with: \"%s\"\n", delay, value); if (alljoyn_message_isencrypted(msg) == QCC_TRUE) { printf("Authenticated using %s\n", alljoyn_message_getauthmechanism(msg)); } #ifdef _WIN32 Sleep(delay); #else usleep(100 * delay); #endif outArg = alljoyn_msgarg_create_and_set("s", value); status = alljoyn_busobject_methodreply_args(busobject, msg, outArg, 1); if (ER_OK != status) { printf("DelayedPing: Error sending reply %s\n", QCC_StatusText(status)); } /* Destroy the msgarg */ alljoyn_msgarg_destroy(outArg); }
void AJ_CALL ping(alljoyn_busobject busobject, const alljoyn_interfacedescription_member* member, alljoyn_message msg) { QStatus status = ER_OK; char*value = NULL; alljoyn_msgarg outArg; status = alljoyn_msgarg_get(alljoyn_message_getarg(msg, 0), "s", &value); if (ER_OK != status) { printf("Ping: Error reading alljoyn_message %s\n", QCC_StatusText(status)); } else { printf("Pinged with: %s\n", value); } if (alljoyn_message_isencrypted(msg) == QCC_TRUE) { printf("Authenticated using %s\n", alljoyn_message_getauthmechanism(msg)); } outArg = alljoyn_msgarg_create_and_set("s", value); status = alljoyn_busobject_methodreply_args(busobject, msg, outArg, 1); if (ER_OK != status) { printf("Ping: Error sending reply %s\n", QCC_StatusText(status)); } /* Destroy the msgarg */ alljoyn_msgarg_destroy(outArg); }
QStatus AJ_CALL property_set(const void* context, const char* ifcName, const char* propName, alljoyn_msgarg val) { QStatus status = ER_OK; int set_i; char*set_string; if ((0 == strcmp("int_val", propName)) && (alljoyn_msgarg_gettype(val) == ALLJOYN_INT32)) { status = alljoyn_msgarg_get(val, "i", &set_i); if (ER_OK == status) { g_prop_int_val = set_i; } } else if ((0 == strcmp("str_val", propName)) && (alljoyn_msgarg_gettype(val) == ALLJOYN_STRING)) { status = alljoyn_msgarg_get(val, "s", &set_string); if (ER_OK == status) { strcpy(g_prop_str_val, set_string); } } else if (0 == strcmp("ro_str", propName)) { status = ER_BUS_PROPERTY_ACCESS_DENIED; } else { status = ER_BUS_NO_SUCH_PROPERTY; } return status; }
static void AJ_CALL properties_changed(alljoyn_proxybusobject proxy, const char* intf, const alljoyn_msgarg changed, const alljoyn_msgarg invalidated, void* context) { QStatus status; size_t nelem; alljoyn_msgarg elems; char* location = NULL; struct _listener_ctx* ctx = (struct _listener_ctx*) context; QCC_UNUSED(intf); printf("[listener] Door %s:%s has changed some properties.\n", alljoyn_proxybusobject_getuniquename(proxy), alljoyn_proxybusobject_getpath(proxy)); alljoyn_busattachment_enableconcurrentcallbacks(ctx->bus); status = proxy_get_location(proxy, &location); if (status == ER_OK) { printf("\tThat's actually the door at location %s.\n", (location != NULL) ? location : "<unknown>"); free(location); } if (ER_OK == status) { status = alljoyn_msgarg_get(changed, "a{sv}", &nelem, &elems); } if (ER_OK == status) { size_t i; for (i = 0; i < nelem; ++i) { const char* prop; alljoyn_msgarg val; status = alljoyn_msgarg_get(alljoyn_msgarg_array_element(elems, i), "{sv}", &prop, &val); if (ER_OK == status) { if (!strcmp(prop, "Location")) { char* newloc; status = alljoyn_msgarg_get_string(val, &newloc); if (ER_OK == status) { printf("-> location: %s\n", newloc); } } else if (!strcmp(prop, "IsOpen")) { QCC_BOOL isopen = QCC_FALSE; status = alljoyn_msgarg_get_bool(val, &isopen); if (ER_OK == status) { printf("-> is open: %s\n", isopen ? "yes" : "no"); } } } else { break; } } } if (ER_OK == status) { status = alljoyn_msgarg_get(invalidated, "as", &nelem, &elems); } if (ER_OK == status) { size_t i; for (i = 0; i < nelem; ++i) { char* prop; status = alljoyn_msgarg_get(alljoyn_msgarg_array_element(elems, i), "s", &prop); if (status == ER_OK) { printf(" invalidated %s\n", prop); } } } printf("> "); fflush(stdout); }
/** Main entry point */ int CDECL_CALL main(void) { QStatus status = ER_OK; alljoyn_interfacedescription testIntf = NULL; alljoyn_buslistener_callbacks callbacks = { NULL, NULL, &found_advertised_name, NULL, &name_owner_changed, NULL, NULL, NULL }; unsigned int count = 0; if (alljoyn_init() != ER_OK) { return 1; } #ifdef ROUTER if (alljoyn_routerinit() != ER_OK) { alljoyn_shutdown(); return 1; } #endif printf("AllJoyn Library version: %s\n", alljoyn_getversion()); printf("AllJoyn Library build info: %s\n", alljoyn_getbuildinfo()); /* Install SIGINT handler */ signal(SIGINT, SigIntHandler); /* Create message bus */ g_msgBus = alljoyn_busattachment_create("SRPSecurityClientC", QCC_TRUE); /* Add org.alljoyn.bus.samples.secure.SecureInterface interface */ status = alljoyn_busattachment_createinterface_secure(g_msgBus, INTERFACE_NAME, &testIntf, AJ_IFC_SECURITY_REQUIRED); if (status == ER_OK) { alljoyn_interfacedescription_addmember(testIntf, ALLJOYN_MESSAGE_METHOD_CALL, "Ping", "s", "s", "inStr1,outStr", 0); alljoyn_interfacedescription_activate(testIntf); } else { printf("Failed to create interface %s\n", INTERFACE_NAME); } /* Start the msg bus */ if (ER_OK == status) { status = alljoyn_busattachment_start(g_msgBus); if (ER_OK != status) { printf("alljoyn_busattachment_start failed\n"); } else { printf("alljoyn_busattachment started.\n"); } } /* * enable security * note the location of the keystore file has been specified and the * isShared parameter is being set to true. So this keystore file can * be used by multiple applications */ if (ER_OK == status) { alljoyn_authlistener_callbacks callbacks = { request_credentials, NULL, NULL, authentication_complete }; g_authListener = alljoyn_authlistener_create(&callbacks, NULL); /* * alljoyn_busattachment_enablepeersecurity function is called by * applications that want to use authentication and encryption. This * function call must be made after alljoyn_busattachment_start and * before calling alljoyn_busattachment_connect. * * In most situations a per-application keystore file is generated. * However, this code specifies the location of the keystore file and * the isShared parameter is being set to QCC_TRUE. The resulting * keystore file can be used by multiple applications. */ status = alljoyn_busattachment_enablepeersecurity(g_msgBus, "ALLJOYN_SRP_KEYX", g_authListener, "/.alljoyn_keystore/central.ks", QCC_TRUE); if (ER_OK != status) { printf("alljoyn_busattachment_enablepeersecurity failed (%s)\n", QCC_StatusText(status)); } else { printf("alljoyn_busattachment_enablepeersecurity Successful\n"); } } /* Connect to the bus */ if (ER_OK == status) { status = alljoyn_busattachment_connect(g_msgBus, NULL); if (ER_OK != status) { printf("alljoyn_busattachment_connect() failed with status: 0x%04x\n", status); } else { printf("alljoyn_busattachment connected to \"%s\"\n", alljoyn_busattachment_getconnectspec(g_msgBus)); } } /* Create a bus listener */ g_busListener = alljoyn_buslistener_create(&callbacks, NULL); /* Register a bus listener in order to get discovery indications */ if (ER_OK == status) { alljoyn_busattachment_registerbuslistener(g_msgBus, g_busListener); printf("alljoyn_buslistener Registered.\n"); } /* Begin discovery on the well-known name of the service to be called */ if (ER_OK == status) { status = alljoyn_busattachment_findadvertisedname(g_msgBus, OBJECT_NAME); if (status != ER_OK) { printf("alljoyn_busattachment_findadvertisedname failed (%s))\n", QCC_StatusText(status)); } } /* Wait for join session to complete */ while (!s_joinComplete && !g_interrupt) { if (0 == (count++ % 10)) { printf("Waited %u seconds for alljoyn_busattachment_joinsession completion.\n", count / 10); } #ifdef _WIN32 Sleep(100); #else usleep(100 * 1000); #endif } if (status == ER_OK && g_interrupt == QCC_FALSE) { alljoyn_message reply; alljoyn_msgarg inputs; size_t numArgs; alljoyn_proxybusobject remoteObj = alljoyn_proxybusobject_create(g_msgBus, OBJECT_NAME, OBJECT_PATH, s_sessionId); const alljoyn_interfacedescription alljoynTestIntf = alljoyn_busattachment_getinterface(g_msgBus, INTERFACE_NAME); QCC_ASSERT(alljoynTestIntf); alljoyn_proxybusobject_addinterface(remoteObj, alljoynTestIntf); /* * Although AllJoyn will automatically try and establish a secure connection * when a method call is made. It will only allow the user the amount of time * specified in the methodcall timeout parameter to enter user input. For the * "Ping" method that is 5 seconds. This is not a reasonable amount of time * for a user to see the security password and enter it. * * By calling alljoyn_proxybusobject_secureconnection the user will have * as much time as they need to to enter the security password to secure * the connection. */ status = alljoyn_proxybusobject_secureconnection(remoteObj, QCC_TRUE); if (ER_OK == status) { reply = alljoyn_message_create(g_msgBus); inputs = alljoyn_msgarg_array_create(1); numArgs = 1; status = alljoyn_msgarg_array_set(inputs, &numArgs, "s", "ClientC says Hello AllJoyn!"); status = alljoyn_proxybusobject_methodcall(remoteObj, INTERFACE_NAME, "Ping", inputs, 1, reply, 5000, 0); if (ER_OK == status) { char* ping_str; status = alljoyn_msgarg_get(alljoyn_message_getarg(reply, 0), "s", &ping_str); printf("%s.%s ( path=%s) returned \"%s\"\n", INTERFACE_NAME, "Ping", OBJECT_PATH, ping_str); } else { printf("alljoyn_proxybusobject_methodcall on %s.%s failed\n", INTERFACE_NAME, "Ping"); } alljoyn_msgarg_destroy(inputs); alljoyn_message_destroy(reply); } alljoyn_proxybusobject_destroy(remoteObj); } /* Deallocate bus */ if (g_msgBus) { alljoyn_busattachment deleteMe = g_msgBus; g_msgBus = NULL; alljoyn_busattachment_destroy(deleteMe); } /* Deallocate bus listener */ alljoyn_buslistener_destroy(g_busListener); /* Deallocate auth listener */ alljoyn_authlistener_destroy(g_authListener); printf("exiting with status %d (%s)\n", status, QCC_StatusText(status)); #ifdef ROUTER alljoyn_routershutdown(); #endif alljoyn_shutdown(); return (int) status; }
/** TODO: Make this C89 compatible. */ int CDECL_CALL main(int argc, char** argv, char** envArg) { QStatus status = ER_OK; char* connectArgs = NULL; //alljoyn_interfacedescription testIntf = NULL; /* Create a bus listener */ alljoyn_buslistener_callbacks callbacks = { ®istered, &unregistered, &found_advertised_name, &lost_advertised_name, &name_owner_changed, &stopping, &disconnected, &prop_changed }; if (alljoyn_init() != ER_OK) { return 1; } #ifdef ROUTER printf("Router Init\n"); if (alljoyn_routerinit() != ER_OK) { alljoyn_shutdown(); return 1; } #endif printf("AllJoyn Library version: %s\n", alljoyn_getversion()); printf("AllJoyn Library build info: %s\n", alljoyn_getbuildinfo()); /* Install SIGINT handler */ signal(SIGINT, SigIntHandler); /* Create message bus */ g_msgBus = alljoyn_busattachment_create("myApp", QCC_TRUE); //Name, Allow remote message // g_msgBus = alljoyn_busattachment_create("myApp", QCC_FALSE); //Name, Allow remote message /* Add org.alljoyn.Bus.method_sample interface */ #if 0 status = alljoyn_busattachment_createinterface(g_msgBus, INTERFACE_NAME, &testIntf); if (status == ER_OK) { printf("Interface Created.\n"); alljoyn_interfacedescription_addmember(testIntf, ALLJOYN_MESSAGE_METHOD_CALL, "cat", "ss", "s", "inStr1,inStr2,outStr", 0); alljoyn_interfacedescription_addmember(testIntf, ALLJOYN_MESSAGE_METHOD_CALL, "cat2", "ss", "s", "inStr1,inStr2,outStr", 0); alljoyn_interfacedescription_activate(testIntf); } else { printf("Failed to create interface 'org.alljoyn.Bus.method_sample'\n"); } #endif /* Start the msg bus */ if (ER_OK == status) { status = alljoyn_busattachment_start(g_msgBus); if (ER_OK != status) { printf("alljoyn_busattachment_start failed\n"); } else { printf("alljoyn_busattachment started.\n"); } } /* Connect to the bus */ if (ER_OK == status) { status = alljoyn_busattachment_connect(g_msgBus, connectArgs); if (ER_OK != status) { printf("alljoyn_busattachment_connect(\"%s\") failed\n", (connectArgs) ? connectArgs : "NULL"); } else { printf("alljoyn_busattachment connected to \"%s\"\n", alljoyn_busattachment_getconnectspec(g_msgBus)); } } g_busListener = alljoyn_buslistener_create(&callbacks, NULL); /* Register a bus listener in order to get discovery indications */ if (ER_OK == status) { alljoyn_busattachment_registerbuslistener(g_msgBus, g_busListener); printf("alljoyn_buslistener Registered.\n"); } /* Begin discovery on the well-known name of the service to be called */ if (ER_OK == status) { status = alljoyn_busattachment_findadvertisedname(g_msgBus, OBJECT_NAME); if (status != ER_OK) { printf("alljoyn_busattachment_findadvertisedname failed (%s))\n", QCC_StatusText(status)); } } /* Wait for join session to complete */ while (s_joinComplete == QCC_FALSE && g_interrupt == QCC_FALSE) { #ifdef _WIN32 Sleep(10); #else usleep(100 * 1000); #endif } if (status == ER_OK && g_interrupt == QCC_FALSE) { alljoyn_message reply; alljoyn_msgarg inputs; size_t numArgs; alljoyn_proxybusobject remoteObj = alljoyn_proxybusobject_create(g_msgBus, OBJECT_NAME, OBJECT_PATH, s_sessionId); #if 1 status = alljoyn_proxybusobject_introspectremoteobject(remoteObj); if (status != ER_OK) { printf("Failed to introspect remote object.\n"); } #endif //alljoyn_interfacedescription alljoynTestIntf = alljoyn_busattachment_getinterface(g_msgBus, INTERFACE_NAME); //assert(alljoynTestIntf); //alljoyn_proxybusobject_addinterface(remoteObj, alljoynTestIntf); //alljoyn_proxybusobject_introspectremoteobject(remoteObj); #if 0 alljoynTestIntf = alljoyn_busattachment_getinterface(g_msgBus, "org.freedesktop.DBus.Introspectable"); assert(alljoynTestIntf); alljoyn_proxybusobject_addinterface(remoteObj, alljoynTestIntf); alljoynTestIntf = alljoyn_busattachment_getinterface(g_msgBus, "org.allseen.Introspectable"); assert(alljoynTestIntf); alljoyn_proxybusobject_addinterface(remoteObj, alljoynTestIntf); #endif #if 1 reply = alljoyn_message_create(g_msgBus); inputs = alljoyn_msgarg_array_create(2); numArgs = 2; status = alljoyn_msgarg_array_set(inputs, &numArgs, "ss", "Hello ", "World!"); if (ER_OK != status) { printf("Arg assignment failed: %s\n", QCC_StatusText(status)); } status = alljoyn_proxybusobject_methodcall(remoteObj, INTERFACE_NAME, "cat", inputs, 2, reply, 5000, 0); if (ER_OK == status) { char* cat_str; status = alljoyn_msgarg_get(alljoyn_message_getarg(reply, 0), "s", &cat_str); printf("%s.%s (path=%s) returned \"%s\"\n", INTERFACE_NAME, "cat", OBJECT_PATH, cat_str); } else { printf("MethodCall on %s.%s failed\n", INTERFACE_NAME, "cat"); } #endif reply = alljoyn_message_create(g_msgBus); inputs = alljoyn_msgarg_array_create(2); numArgs = 2; status = alljoyn_msgarg_array_set(inputs, &numArgs, "ss", "Hello ", "World!"); if (ER_OK != status) { printf("Arg assignment failed: %s\n", QCC_StatusText(status)); } status = alljoyn_proxybusobject_methodcall(remoteObj, INTERFACE_NAME, "cat2", inputs, 2, reply, 5000, 0); if (ER_OK == status) { char* cat_str; status = alljoyn_msgarg_get(alljoyn_message_getarg(reply, 0), "s", &cat_str); printf("%s.%s (path=%s) returned \"%s\"\n", INTERFACE_NAME, "cat2", OBJECT_PATH, cat_str); } else { printf("MethodCall on %s.%s failed\n", INTERFACE_NAME, "cat2"); } #if 0 status = alljoyn_proxybusobject_methodcall(remoteObj, "org.freedesktop.DBus.Introspectable", "Introspect", NULL, 0, reply, 5000, 0); if (ER_OK == status) { char* Introspect_str; status = alljoyn_msgarg_get(alljoyn_message_getarg(reply, 0), "s", &Introspect_str); printf("%s.%s (path=%s) returned \"%s\"\n", "org.freedesktop.DBus.Introspectable", "Introspect", OBJECT_PATH, Introspect_str); } else { printf("MethodCall on %s.%s failed\n", "org.freedesktop.DBus.Introspectable", "Introspect"); } #endif alljoyn_proxybusobject_destroy(remoteObj); alljoyn_message_destroy(reply); alljoyn_msgarg_destroy(inputs); } /* Deallocate bus */ if (g_msgBus) { alljoyn_busattachment deleteMe = g_msgBus; g_msgBus = NULL; alljoyn_busattachment_destroy(deleteMe); } /* Deallocate bus listener */ alljoyn_buslistener_destroy(g_busListener); printf("basic client exiting with status %d (%s)\n", status, QCC_StatusText(status)); #ifdef ROUTER printf("Router Shutdown\n"); alljoyn_routershutdown(); #endif alljoyn_shutdown(); return (int) status; }
/** Main entry point */ int CDECL_CALL main(int argc, char** argv) { QStatus status = ER_OK; char* connectArgs = NULL; alljoyn_interfacedescription testIntf = NULL; unsigned long timeoutMs = ULONG_MAX; unsigned long timeMs = 0; /* Create a bus listener */ alljoyn_buslistener_callbacks callbacks = { NULL, NULL, &found_advertised_name, NULL, &name_owner_changed, NULL, NULL, NULL }; if (argc == 2) { char* stopString = NULL; /* Multiply by 1000 to convert seconds to milliseconds */ timeoutMs = strtol(argv[1], &stopString, 10) * 1000; if ((timeoutMs == 0) || (stopString[0] != '\0')) { printf("Parameter was not valid, please provide a valid integer timeout in seconds or do not provide a parameter to never time out.\n"); return ER_BAD_ARG_1; } } else if (argc > 2) { printf("This app only accepts a single parameter, an integer connection timeout in seconds. For an unlimited timeout, do not provide a parameter.\n"); return ER_BAD_ARG_COUNT; } if (alljoyn_init() != ER_OK) { return 1; } #ifdef ROUTER if (alljoyn_routerinit() != ER_OK) { alljoyn_shutdown(); return 1; } #endif printf("AllJoyn Library version: %s\n", alljoyn_getversion()); printf("AllJoyn Library build info: %s\n", alljoyn_getbuildinfo()); /* Install SIGINT handler */ signal(SIGINT, SigIntHandler); /* Create message bus */ if (status == ER_OK) { g_msgBus = alljoyn_busattachment_create("myApp", QCC_TRUE); } /* Add org.alljoyn.Bus.method_sample interface */ if (status == ER_OK) { status = alljoyn_busattachment_createinterface(g_msgBus, INTERFACE_NAME, &testIntf); } if (status == ER_OK) { printf("Interface Created.\n"); alljoyn_interfacedescription_addmember(testIntf, ALLJOYN_MESSAGE_METHOD_CALL, "cat", "ss", "s", "inStr1,inStr2,outStr", 0); alljoyn_interfacedescription_activate(testIntf); } else { printf("Failed to create interface 'org.alljoyn.Bus.method_sample'\n"); } /* Start the msg bus */ if (ER_OK == status) { status = alljoyn_busattachment_start(g_msgBus); if (ER_OK != status) { printf("alljoyn_busattachment_start failed\n"); } else { printf("alljoyn_busattachment started.\n"); } } /* Connect to the bus */ if (ER_OK == status) { status = alljoyn_busattachment_connect(g_msgBus, connectArgs); if (ER_OK != status) { printf("alljoyn_busattachment_connect(\"%s\") failed\n", (connectArgs) ? connectArgs : "NULL"); } else { printf("alljoyn_busattachment connected to \"%s\"\n", alljoyn_busattachment_getconnectspec(g_msgBus)); } } if (status == ER_OK) { g_busListener = alljoyn_buslistener_create(&callbacks, NULL); } /* Register a bus listener in order to get discovery indications */ if (ER_OK == status) { alljoyn_busattachment_registerbuslistener(g_msgBus, g_busListener); printf("alljoyn_buslistener Registered.\n"); } /* Begin discovery on the well-known name of the service to be called */ if (ER_OK == status) { status = alljoyn_busattachment_findadvertisedname(g_msgBus, OBJECT_NAME); if (status != ER_OK) { printf("alljoyn_busattachment_findadvertisedname failed (%s))\n", QCC_StatusText(status)); } } /* Wait for join session to complete */ while ((status == ER_OK) && (s_joinComplete == QCC_FALSE) && (g_interrupt == QCC_FALSE) && (timeMs < timeoutMs)) { #ifdef _WIN32 Sleep(10); #else usleep(10 * 1000); #endif timeMs += 10; } if (timeMs >= timeoutMs) { status = ER_BUS_ESTABLISH_FAILED; printf("Failed to connect before timeout (%s)\n", QCC_StatusText(status)); } if ((status == ER_OK) && (g_interrupt == QCC_FALSE)) { alljoyn_message reply; alljoyn_msgarg inputs; size_t numArgs; alljoyn_proxybusobject remoteObj = alljoyn_proxybusobject_create(g_msgBus, OBJECT_NAME, OBJECT_PATH, s_sessionId); const alljoyn_interfacedescription alljoynTestIntf = alljoyn_busattachment_getinterface(g_msgBus, INTERFACE_NAME); assert(alljoynTestIntf); alljoyn_proxybusobject_addinterface(remoteObj, alljoynTestIntf); reply = alljoyn_message_create(g_msgBus); inputs = alljoyn_msgarg_array_create(2); numArgs = 2; status = alljoyn_msgarg_array_set(inputs, &numArgs, "ss", "Hello ", "World!"); if (ER_OK != status) { printf("Arg assignment failed: %s\n", QCC_StatusText(status)); } status = alljoyn_proxybusobject_methodcall(remoteObj, INTERFACE_NAME, "cat", inputs, 2, reply, 5000, 0); if (ER_OK == status) { char* cat_str; status = alljoyn_msgarg_get(alljoyn_message_getarg(reply, 0), "s", &cat_str); printf("%s.%s ( path=%s) returned \"%s\"\n", INTERFACE_NAME, "cat", OBJECT_PATH, cat_str); } else { printf("MethodCall on %s.%s failed\n", INTERFACE_NAME, "cat"); } alljoyn_proxybusobject_destroy(remoteObj); alljoyn_message_destroy(reply); alljoyn_msgarg_destroy(inputs); } /* Deallocate bus */ if (g_msgBus) { alljoyn_busattachment deleteMe = g_msgBus; g_msgBus = NULL; alljoyn_busattachment_destroy(deleteMe); } /* Deallocate bus listener */ if (g_busListener) { alljoyn_buslistener_destroy(g_busListener); } printf("basic client exiting with status %d (%s)\n", status, QCC_StatusText(status)); #ifdef ROUTER alljoyn_routershutdown(); #endif alljoyn_shutdown(); return (int) status; }