本文整理汇总了C++中InterfaceDescription::AddSignal方法的典型用法代码示例。如果您正苦于以下问题:C++ InterfaceDescription::AddSignal方法的具体用法?C++ InterfaceDescription::AddSignal怎么用?C++ InterfaceDescription::AddSignal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InterfaceDescription
的用法示例。
在下文中一共展示了InterfaceDescription::AddSignal方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: CreateInterfaces
bool ChatObject::CreateInterfaces()
{
const char* ifName = CHAT_SERVICE_INTERFACE_NAME;
InterfaceDescription* chatIntf = NULL;
status = ajConnection->busAttachment->CreateInterface(ifName, chatIntf);
assert(chatIntf);
if (ER_OK == status) {
chatIntf->AddSignal("Chat", "s", "str", 0);
chatIntf->Activate();
} else {
NotifyUser(MSG_ERROR, "Failed to create interface \"%s\" (%s)\n", CHAT_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
return false;
}
NotifyUser(MSG_SYSTEM, "Create interface \"%s\" (%s)\n", CHAT_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
return true;
}
示例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;
}
示例4: createMessageBus
void ChatConnection::createMessageBus()
{
QStatus status = ER_OK;
NotifyUser(MSG_STATUS, "Create message bus.");
ajn::BusAttachment* bus = new BusAttachment("chat", true);
this->busAttachment = bus;
this->busListener = new MyBusListener();
this->busListener->SetListenCallback(JoinNotifier);
this->busListener->SetConnection(this);
/* Create org.alljoyn.bus.samples.chat interface */
InterfaceDescription* chatIntf;
status = bus->CreateInterface(CHAT_SERVICE_INTERFACE_NAME, chatIntf);
if (ER_OK == status) {
chatIntf->AddSignal("Chat", "s", "str", 0);
chatIntf->Activate();
} else {
NotifyUser(MSG_ERROR, "Failed to create interface \"%s\" (%s)\n", CHAT_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
}
/* Create and register the bus object that will be used to send and receive signals */
ChatObject* chatObject = new ChatObject(*bus, CHAT_SERVICE_OBJECT_PATH);
this->chatObject = chatObject;
this->busAttachment->RegisterBusObject(*chatObject);
chatObject->SetConnection(this);
}
示例5: LOGE
/**
* Initialize AllJoyn and connect to local daemon.
*/
JNIEXPORT jint JNICALL Java_org_alljoyn_bus_samples_chat_Chat_jniOnCreate(JNIEnv* env, jobject jobj,
jstring packageNameStrObj)
{
QStatus status = ER_OK;
const char* packageNameStr = NULL;
InterfaceDescription* chatIntf = NULL;
const char* daemonAddr = "unix:abstract=alljoyn";
JavaVM* vm;
jobject jglobalObj = NULL;
packageNameStr = env->GetStringUTFChars(packageNameStrObj, NULL);
if (!packageNameStr) {
LOGE("GetStringUTFChars failed");
status = ER_FAIL;
goto exit;
}
/* Create message bus */
s_bus = new BusAttachment(packageNameStr, true);
if (!s_bus) {
LOGE("new BusAttachment failed");
status = ER_FAIL;
goto exit;
}
/* Create org.alljoyn.bus.samples.chat interface */
status = s_bus->CreateInterface(CHAT_SERVICE_INTERFACE_NAME, chatIntf);
if (ER_OK != status) {
LOGE("Failed to create interface \"%s\" (%s)", CHAT_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
goto exit;
}
status = chatIntf->AddSignal("Chat", "s", "str", 0);
if (ER_OK != status) {
LOGE("Failed to AddSignal \"Chat\" (%s)", QCC_StatusText(status));
goto exit;
}
chatIntf->Activate();
/* Start the msg bus */
status = s_bus->Start();
if (ER_OK != status) {
LOGE("BusAttachment::Start failed (%s)", QCC_StatusText(status));
goto exit;
}
/* Connect to the daemon */
status = s_bus->Connect(daemonAddr);
if (ER_OK != status) {
LOGE("BusAttachment::Connect(\"%s\") failed (%s)", daemonAddr, QCC_StatusText(status));
goto exit;
}
/* Create and register the bus object that will be used to send out signals */
if (0 != env->GetJavaVM(&vm)) {
LOGE("GetJavaVM failed");
status = ER_FAIL;
goto exit;
}
jglobalObj = env->NewGlobalRef(jobj);
if (!jglobalObj) {
LOGE("NewGlobalRef failed");
status = ER_FAIL;
goto exit;
}
s_chatObj = new ChatObject(*s_bus, CHAT_SERVICE_OBJECT_PATH, vm, jglobalObj);
if (!s_chatObj) {
LOGE("new ChatObject failed");
status = ER_FAIL;
goto exit;
}
jglobalObj = NULL; /* ChatObject owns global reference now */
status = s_bus->RegisterBusObject(*s_chatObj);
if (ER_OK != status) {
LOGE("BusAttachment::RegisterBusObject() failed (%s)", QCC_StatusText(status));
goto exit;
}
LOGD("\n Bus Object created and registered \n");
/* Register a bus listener in order to get discovery indications */
s_busListener = new MyBusListener();
if (!s_busListener) {
LOGE("new BusListener failed");
status = ER_FAIL;
goto exit;
}
s_bus->RegisterBusListener(*s_busListener);
exit:
if (ER_OK != status) {
delete s_bus;
s_bus = NULL;
delete s_chatObj;
s_chatObj = NULL;
delete s_busListener;
s_busListener = NULL;
//.........这里部分代码省略.........