当前位置: 首页>>代码示例>>C++>>正文


C++ InterfaceDescription::AddMethod方法代码示例

本文整理汇总了C++中InterfaceDescription::AddMethod方法的典型用法代码示例。如果您正苦于以下问题:C++ InterfaceDescription::AddMethod方法的具体用法?C++ InterfaceDescription::AddMethod怎么用?C++ InterfaceDescription::AddMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在InterfaceDescription的用法示例。


在下文中一共展示了InterfaceDescription::AddMethod方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateInterface

QStatus CreateInterface(string interfaceName)
{
    InterfaceDescription *intf = NULL;
    QStatus status = s_msgBus->CreateInterface(interfaceName.c_str(), intf);

    if (ER_OK == status) {
        cout << "Created message interface" <<endl;
        intf->AddMethod("on", "y", "s", "pinNum, ackStr", 0);
        intf->AddMethod("off", "y", "s", "pinNum, ackStr", 0);
        intf->Activate();
    } else {
        cout << "Could not create interface '"<< interfaceName <<"'" << endl;
    }

    return status;
}
开发者ID:thecodemaiden,项目名称:alljoyn-iot-pi,代码行数:16,代码来源:led_client.cpp

示例2: CreateInterfaces

bool XferObject::CreateInterfaces()
{
    const char* ifName = XFER_SERVICE_INTERFACE_NAME;
    InterfaceDescription* xferIntf = NULL;
    status = ajConnection->busAttachment->CreateInterface(ifName, xferIntf);
    assert(xferIntf);
    if (ER_OK == status) {
        xferIntf->AddMethod("query", "si",  "i", "filename, filesize, acceptsize ", 0);
        xferIntf->AddMethod("initiate", "ii",  "i", "segmentSize, nSegs, acceptsize ", 0);
        xferIntf->AddMethod("receive", "ayii",  "i", "segment, serialNum. segSize , success ", 0);
        xferIntf->AddMethod("status", "i",  "i", "unused , status ", 0);
        xferIntf->AddMethod("close", "i",  "i", "unused , success ", 0);
        xferIntf->AddMethod("error", "i",  "i", "unused , error ", 0);
        xferIntf->Activate();
    } else {
        NotifyUser(MSG_ERROR, "Failed to create interface \"%s\" (%s)\n", XFER_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
        return false;
    }
    NotifyUser(MSG_SYSTEM, "Create interface \"%s\" (%s)\n", XFER_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
    return true;
}
开发者ID:peterdocter,项目名称:Coco2dxDemo,代码行数:21,代码来源:AllJoynConnection.cpp

示例3: BuildInterface

static QStatus BuildInterface(BusAttachment& bus)
{
    QStatus status;

    InterfaceDescription* intf = NULL;
    status = bus.CreateInterface(INTF_NAME, intf);
    QCC_ASSERT(ER_OK == status);
    status = intf->AddProperty("IsOpen", "b", PROP_ACCESS_READ);
    QCC_ASSERT(ER_OK == status);
    status = intf->AddPropertyAnnotation("IsOpen", "org.freedesktop.DBus.Property.EmitsChangedSignal", "true");
    QCC_ASSERT(ER_OK == status);
    status = intf->AddProperty("Location", "s", PROP_ACCESS_READ);
    QCC_ASSERT(ER_OK == status);
    status = intf->AddPropertyAnnotation("Location", "org.freedesktop.DBus.Property.EmitsChangedSignal", "true");
    QCC_ASSERT(ER_OK == status);
    status = intf->AddProperty("KeyCode", "u", PROP_ACCESS_READ);
    QCC_ASSERT(ER_OK == status);
    status = intf->AddPropertyAnnotation("KeyCode", "org.freedesktop.DBus.Property.EmitsChangedSignal", "invalidates");
    QCC_ASSERT(ER_OK == status);

    status = intf->AddMethod("Open", "", "", "");
    QCC_ASSERT(ER_OK == status);
    status = intf->AddMethod("Close", "", "", "");
    QCC_ASSERT(ER_OK == status);
    status = intf->AddMethod("KnockAndRun", "", "", "", MEMBER_ANNOTATE_NO_REPLY);
    QCC_ASSERT(ER_OK == status);

    status = intf->AddMethod("GetUI", "", "s", "outStr", 0);
    QCC_ASSERT(ER_OK == status);

    status = intf->AddMethod("CallFunc", "s", "s", "in", 0);
    QCC_ASSERT(ER_OK == status);

    status = intf->AddSignal("PersonPassedThrough", "s", "name", MEMBER_ANNOTATE_SESSIONCAST);
    QCC_ASSERT(ER_OK == status);

    intf->Activate();

    return status;
}
开发者ID:eugene-pro,项目名称:consumer,代码行数:40,代码来源:main.cpp

示例4: main

int CDECL_CALL main()
{
    if (AllJoynInit() != ER_OK) {
        return 1;
    }
#ifdef ROUTER
    if (AllJoynRouterInit() != ER_OK) {
        AllJoynShutdown();
        return 1;
    }
#endif
    {
        BusAttachment busAttachment("AddInterfaceFromCode", true);
        busAttachment.Start();

        /// [code_interface_adding_to_busAttachment]
        InterfaceDescription* exampleIntf = NULL;
        QStatus status = busAttachment.CreateInterface(::com::example::name, exampleIntf);
        if (ER_OK == status) {
            status = exampleIntf->AddMethod("Echo", "s", "s", "input_arg,return_arg");
        }
        if (ER_OK == status) {
            status = exampleIntf->AddSignal("Chirp", "s", "sound", MEMBER_ANNOTATE_SESSIONCAST);
        }
        if (ER_OK == status) {
            status = exampleIntf->AddProperty("Volume", "i", PROP_ACCESS_RW);
        }
        if (ER_OK == status) {
            exampleIntf->Activate();
        } else {
            printf("Failed to create interface %s\n", ::com::example::name);
        }
        /// [code_interface_adding_to_busAttachment]

        const InterfaceDescription* interfaceFromBus = busAttachment.GetInterface(::com::example::name);
        if (interfaceFromBus == NULL) {
            printf("Failed to Get %s\n", ::com::example::name);
        } else {
            printf("Read the %s interface back from the BusAttachment.\n%s\n", ::com::example::name, interfaceFromBus->Introspect().c_str());
        }
    }
#ifdef ROUTER
    AllJoynRouterShutdown();
#endif
    AllJoynShutdown();
    return 0;
}
开发者ID:avernon,项目名称:asl_distribution,代码行数:47,代码来源:create_interface_using_code.cpp

示例5: main

/** Main entry point */
int main(int argc, char** argv, char** envArg)
{
    QStatus status = ER_OK;

    printf("AllJoyn Library version: %s\n", ajn::GetVersion());
    printf("AllJoyn Library build info: %s\n", ajn::GetBuildInfo());

    /* Install SIGINT handler */
    signal(SIGINT, SigIntHandler);

#ifdef _WIN32
    qcc::String connectArgs = "tcp:addr=127.0.0.1,port=9956";
#else
    qcc::String connectArgs = "unix:abstract=bluebus";
#endif

    /* Create message bus */
    g_msgBus = new BusAttachment("myApp", true);


    /* Add org.alljoyn.Bus.method_sample interface */
    InterfaceDescription* testIntf = NULL;
    status = g_msgBus->CreateInterface(SERVICE_NAME, testIntf);
    if (status == ER_OK) {
        printf("Interface Created.\n");
        testIntf->AddMethod("cat", "ss",  "s", "inStr1,inStr2,outStr", 0);
        testIntf->Activate();
    } else {
        printf("Failed to create interface 'org.alljoyn.Bus.method_sample'\n");
    }

    /* Start the msg bus */
    status = g_msgBus->Start();
    if (ER_OK == status) {
        printf("BusAttachement started.\n");
        /* Register  local objects and connect to the daemon */
        BasicSampleObject testObj(*g_msgBus, SERVICE_PATH);
        g_msgBus->RegisterBusObject(testObj);

        /* Create the client-side endpoint */
        status = g_msgBus->Connect(connectArgs.c_str());
        if (ER_OK != status) {
            printf("Failed to connect to \"%s\"\n", connectArgs.c_str());
            exit(1);
        } else {
            printf("Connected to '%s'\n", connectArgs.c_str());
        }

        if (ER_OK == status) {
            while (g_interrupt == false) {
#ifdef _WIN32
                Sleep(100);
#else
                usleep(100 * 1000);
#endif
            }
        }
    } else {
        printf("BusAttachment::Start failed\n");
    }

    /* Clean up msg bus */
    if (g_msgBus) {
        BusAttachment* deleteMe = g_msgBus;
        g_msgBus = NULL;
        delete deleteMe;
    }

    return (int) status;
}
开发者ID:kalperin,项目名称:alljoyn_core,代码行数:71,代码来源:Service.cpp

示例6: main

/** Main entry point */
int main(int argc, char** argv, char** envArg)
{
    QStatus status = ER_OK;

    printf("AllJoyn Library version: %s\n", ajn::GetVersion());
    printf("AllJoyn Library build info: %s\n", ajn::GetBuildInfo());

    /* Install SIGINT handler */
    signal(SIGINT, SigIntHandler);

    const char* connectArgs = getenv("BUS_ADDRESS");
    if (connectArgs == NULL) {
#ifdef _WIN32
        connectArgs = "tcp:addr=127.0.0.1,port=9956";
#else
        connectArgs = "unix:abstract=alljoyn";
#endif
    }

    /* Create message bus */
    g_msgBus = new BusAttachment("myApp", true);

    /* Add org.alljoyn.Bus.method_sample interface */
    InterfaceDescription* testIntf = NULL;
    status = g_msgBus->CreateInterface(INTERFACE_NAME, testIntf);
    if (status == ER_OK) {
        printf("Interface Created.\n");
        testIntf->AddMethod("cat", "ss",  "s", "inStr1,inStr2,outStr", 0);
        testIntf->Activate();
    } else {
        printf("Failed to create interface 'org.alljoyn.Bus.method_sample'\n");
    }


    /* Start the msg bus */
    if (ER_OK == status) {
        status = g_msgBus->Start();
        if (ER_OK != status) {
            printf("BusAttachment::Start failed\n");
        } else {
            printf("BusAttachment started.\n");
        }
    }

    /* Connect to the bus */
    if (ER_OK == status) {
        status = g_msgBus->Connect(connectArgs);
        if (ER_OK != status) {
            printf("BusAttachment::Connect(\"%s\") failed\n", connectArgs);
        } else {
            printf("BusAttchement connected to %s\n", connectArgs);
        }
    }

    /* Register a bus listener in order to get discovery indications */
    if (ER_OK == status) {
        g_msgBus->RegisterBusListener(g_busListener);
        printf("BusListener Registered.\n");
    }

    /* Begin discovery on the well-known name of the service to be called */
    if (ER_OK == status) {
        status = g_msgBus->FindAdvertisedName(SERVICE_NAME);
        if (status != ER_OK) {
            printf("org.alljoyn.Bus.FindAdvertisedName failed (%s))\n", QCC_StatusText(status));
        }
    }

    /* Wait for join session to complete */
    while (!s_joinComplete  && !g_interrupt) {
#ifdef _WIN32
        Sleep(1000);
#else
        usleep(100 * 1000);
#endif
    }

    if (status == ER_OK && g_interrupt == false) {
        ProxyBusObject remoteObj(*g_msgBus, SERVICE_NAME, SERVICE_PATH, s_sessionId);
        const InterfaceDescription* alljoynTestIntf = g_msgBus->GetInterface(INTERFACE_NAME);
        assert(alljoynTestIntf);
        remoteObj.AddInterface(*alljoynTestIntf);

        Message reply(*g_msgBus);
        MsgArg inputs[2];
        inputs[0].Set("s", "Hello ");
        inputs[1].Set("s", "World!");
        status = remoteObj.MethodCall(SERVICE_NAME, "cat", inputs, 2, reply, 5000);
        if (ER_OK == status) {
            printf("%s.%s ( path=%s) returned \"%s\"\n", SERVICE_NAME, "cat",
                   SERVICE_PATH, reply->GetArg(0)->v_string.str);
        } else {
            printf("MethodCall on %s.%s failed", SERVICE_NAME, "cat");
        }
    }

    /* Deallocate bus */
    if (g_msgBus) {
        BusAttachment* deleteMe = g_msgBus;
//.........这里部分代码省略.........
开发者ID:Moutie,项目名称:alljoyn_core,代码行数:101,代码来源:Client.cpp

示例7: opts

/*
 * Class:     org_alljoyn_bus_samples_simpleservice_Service
 * Method:    startService
 * Signature: (Ljava/lang/String;Ljava/lang/String;)Z
 */
JNIEXPORT jboolean JNICALL Java_org_alljoyn_bus_samples_simpleservice_Service_startService(JNIEnv* env, jobject jobj,
                                                                                           jstring jServiceName, jstring packageNameStrObj)
{
    QStatus status = ER_OK;

    jboolean iscopy;
    const char* serviceNameStr = env->GetStringUTFChars(jServiceName, &iscopy);
    serviceName = "";
    serviceName += SIMPLE_SERVICE_WELL_KNOWN_NAME_PREFIX;
    serviceName += serviceNameStr;

    SessionOpts opts(SessionOpts::TRAFFIC_MESSAGES, false, SessionOpts::PROXIMITY_ANY, TRANSPORT_ANY);

    const char* daemonAddr = "unix:abstract=alljoyn";

    /* Initialize AllJoyn only once */
    if (!s_bus) {
        const char* packageNameStr = env->GetStringUTFChars(packageNameStrObj, &iscopy);
        s_bus = new BusAttachment("service", true);

        /* Add org.alljoyn.samples.simple interface */
        InterfaceDescription* testIntf = NULL;
        status = s_bus->CreateInterface(SIMPLE_SERVICE_INTERFACE_NAME, testIntf);
        if (ER_OK == status) {
            testIntf->AddMethod("Ping", "s",  "s", "inStr,outStr", 0);
            testIntf->Activate();
        } else {
            LOGE("Failed to create interface %s (%s)", SIMPLE_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
        }

        /* Start the msg bus */
        if (ER_OK == status) {
            status = s_bus->Start();
        } else {
            LOGE("BusAttachment::Start failed (%s)", QCC_StatusText(status));
        }

        /* Connect to the daemon */
        if (ER_OK == status) {
            status = s_bus->Connect(daemonAddr);
            if (ER_OK != status) {
                LOGE("Connect to %s failed (%s)", daemonAddr, QCC_StatusText(status));
            }
        }

        /* Register the bus listener */
        JavaVM* vm;
        env->GetJavaVM(&vm);
        if (ER_OK == status) {
            s_busListener = new MyBusListener(vm, jobj);
            s_bus->RegisterBusListener(*s_busListener);
            LOGD("\n Bus Listener registered \n");
        }

        /* Register service object */
        s_obj = new ServiceObject(*s_bus, SIMPLE_SERVICE_OBJECT_PATH, vm, jobj);
        s_bus->RegisterBusObject(*s_obj);

        /* Bind the session port*/
        if (ER_OK == status) {
            SessionPort sp = SESSION_PORT;
            status = s_bus->BindSessionPort(sp, opts, *s_busListener);
            if (ER_OK != status) {
                LOGE("BindSessionPort failed (%s)\n", QCC_StatusText(status));
            } else {
                LOGD("\n Bind Session Port to %d was successful \n", SESSION_PORT);
            }
        }
        env->ReleaseStringUTFChars(packageNameStrObj, packageNameStr);
    }

    /* Request name */
    status = s_bus->RequestName(serviceName.c_str(), DBUS_NAME_FLAG_DO_NOT_QUEUE);
    if (ER_OK != status) {
        LOGE("RequestName(%s) failed (status=%s)\n", serviceName.c_str(), QCC_StatusText(status));
        status = (status == ER_OK) ? ER_FAIL : status;
    } else {
        LOGD("\n Request Name was successful");
    }

    /* Advertise the name */
    if (ER_OK == status) {

        status = s_bus->AdvertiseName(serviceName.c_str(), opts.transports);
        if (status != ER_OK) {
            LOGD("Failed to advertise name %s (%s) \n", serviceName.c_str(), QCC_StatusText(status));
        } else {
            LOGD("\n Name %s was successfully advertised", serviceName.c_str());
        }
    }
    env->ReleaseStringUTFChars(jServiceName, serviceNameStr);
    env->DeleteLocalRef(jServiceName);
    return (jboolean) true;
}
开发者ID:GameClay,项目名称:alljoyn_core,代码行数:99,代码来源:Service_jni.cpp


注:本文中的InterfaceDescription::AddMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。