Esempio n. 1
0
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);
}
Esempio n. 2
0
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);
}
Esempio n. 3
0
/* 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);
}
Esempio n. 4
0
void AJ_CALL time_ping(alljoyn_busobject busobject, const alljoyn_interfacedescription_member* member, alljoyn_message msg)
{
    QStatus status = ER_OK;
    size_t numArgs = 0;
    alljoyn_msgarg args[2];

    /* Reply with same data that was sent to us */
    alljoyn_message_getargs(msg, &numArgs, args);

    status = alljoyn_busobject_methodreply_args(busobject, msg, *args, numArgs);
    if (ER_OK != status) {
        printf("TimePing: Error sending reply %s\n", QCC_StatusText(status));
    }
}