本文整理汇总了C++中Messenger::get方法的典型用法代码示例。如果您正苦于以下问题:C++ Messenger::get方法的具体用法?C++ Messenger::get怎么用?C++ Messenger::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Messenger
的用法示例。
在下文中一共展示了Messenger::get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: interactiveCustomCatalogTests
static void interactiveCustomCatalogTests(Node& node, TestRunner& tr)
{
Messenger* messenger = node.getMessenger();
tr.group("customcatalog+listing updater");
// generate the ware URLs that will be used throughout the test.
Url waresUrl;
waresUrl.format("%s/api/3.0/catalog/wares?nodeuser=%" PRIu64,
messenger->getSelfUrl(true).c_str(), TEST_USER_ID);
Url wareUrl;
wareUrl.format("%s/api/3.0/catalog/wares/%s?nodeuser=%" PRIu64,
messenger->getSelfUrl(true).c_str(), TEST_WARE_ID_2, TEST_USER_ID);
// generate the files URL that will be used to prime the medialibrary
Url filesUrl;
filesUrl.format("%s/api/3.2/medialibrary/files?nodeuser=%" PRIu64,
messenger->getSelfUrl(true).c_str(), TEST_USER_ID);
Url removeUrl;
removeUrl.format(
"%s/api/3.2/medialibrary/files/%s?nodeuser=%" PRIu64,
messenger->getSelfUrl(true).c_str(), TEST_FILE_ID_2, TEST_USER_ID);
// remove any previous files from the media library
messenger->deleteResource(&removeUrl, NULL, node.getDefaultUserId());
// pass even if there is an exception - this is meant to just clear any
// previous entries in the medialibrary database if they existed.
Exception::clear();
tr.test("add file to medialibrary (valid)");
{
DynamicObject in;
DynamicObject out;
// create a FileInfo object
string normalizedPath;
File::normalizePath(
(sTestDataDir + TEST_FILENAME_2).c_str(), normalizedPath);
out["path"] = normalizedPath.c_str();
out["mediaId"] = 2;
// prepare event waiter
EventWaiter ew(node.getEventController());
ew.start("bitmunk.medialibrary.File.updated");
ew.start("bitmunk.medialibrary.File.exception");
// add the file to the media library
assertNoException(
messenger->post(&filesUrl, &out, &in, node.getDefaultUserId()));
// wait for file ID set event
assert(ew.waitForEvent(5*1000));
// ensure it has an exception
Event e = ew.popEvent();
//dumpDynamicObject(e);
if(e["details"]->hasMember("exception"))
{
ExceptionRef ex = Exception::convertToException(
e["details"]["exception"]);
Exception::set(ex);
}
}
tr.passIfNoException();
tr.test("add ware without payee-scheme (valid)");
{
DynamicObject in;
DynamicObject out;
// create the outgoing ware object
FileInfo fi;
fi["id"] = TEST_FILE_ID_2;
out["id"] = TEST_WARE_ID_2;
out["mediaId"] = 2;
out["description"] = "This ware was added by test-services-customcatalog";
out["fileInfo"] = fi;
out["payees"]->setType(Array);
Payee p1 = out["payees"]->append();
Payee p2 = out["payees"]->append();
p1["id"] = 900;
p1["amountType"] = PAYEE_AMOUNT_TYPE_FLATFEE;
p1["amount"] = "0.10";
p1["description"] = "This payee is for media ID 2";
p2["id"] = 900;
p2["amountType"] = PAYEE_AMOUNT_TYPE_PTOTAL;
p2["percentage"] = "0.10";
p2["description"] = "This payee is for media ID 2";
// add the ware to the custom catalog
messenger->post(&waresUrl, &out, &in, node.getDefaultUserId());
}
tr.passIfNoException();
printf("\nWaiting for server info to update...\n");
Thread::sleep(2*1000);
//.........这里部分代码省略.........
示例2: customCatalogTests
static void customCatalogTests(Node& node, TestRunner& tr)
{
resetTestEnvironment(node);
Messenger* messenger = node.getMessenger();
// generate the ware URLs that will be used throughout the test.
Url waresUrl;
waresUrl.format(
"%s/api/3.0/catalog/wares?nodeuser=%" PRIu64,
messenger->getSelfUrl(true).c_str(), TEST_USER_ID);
Url waresNonDefaultListUrl;
waresNonDefaultListUrl.format(
"%s/api/3.0/catalog/wares?nodeuser=%" PRIu64 "&id=%s&default=false",
messenger->getSelfUrl(true).c_str(), TEST_USER_ID, TEST_WARE_ID_2);
Url wareUrl;
wareUrl.format(
"%s/api/3.0/catalog/wares/%s?nodeuser=%" PRIu64,
messenger->getSelfUrl(true).c_str(), TEST_WARE_ID_2, TEST_USER_ID);
// generate the files URL that will be used to prime the medialibrary
Url filesUrl;
filesUrl.format("%s/api/3.2/medialibrary/files?nodeuser=%" PRIu64,
messenger->getSelfUrl(true).c_str(), TEST_USER_ID);
Url removeUrl;
removeUrl.format(
"%s/api/3.2/medialibrary/files/%s?nodeuser=%" PRIu64,
messenger->getSelfUrl(true).c_str(), TEST_FILE_ID_2, TEST_USER_ID);
// Create basic and detailed test ware with id=2
Ware basicWare2;
Ware detailedWare2;
{
basicWare2["id"] = TEST_WARE_ID_2;
basicWare2["description"] =
"This ware was added by test-services-customcatalog";
detailedWare2 = basicWare2.clone();
detailedWare2["mediaId"] = 2;
detailedWare2["fileInfos"]->setType(Array);
FileInfo fi = detailedWare2["fileInfos"]->append();
fi["id"] = TEST_FILE_ID_2;
fi["mediaId"] = 2;
File file((sTestDataDir + TEST_FILENAME_2).c_str());
fi["extension"] = file->getExtension() + 1;
fi["contentType"] = "audio/mpeg";
fi["contentSize"] = TEST_CONTENT_SIZE_2;
fi["size"] = (uint64_t)file->getLength();
fi["path"] = file->getAbsolutePath();
detailedWare2["payees"]->setType(Array);
Payee p1 = detailedWare2["payees"]->append();
Payee p2 = detailedWare2["payees"]->append();
p1["id"] = 900;
p1["amountType"] = PAYEE_AMOUNT_TYPE_FLATFEE;
p1["amount"] = "0.10";
p1["description"] = "This payee is for media ID 2";
p2["id"] = 900;
p2["amountType"] = PAYEE_AMOUNT_TYPE_PTOTAL;
p2["percentage"] = "0.10";
p2["description"] = "This payee is for media ID 2";
}
// remove any previous files from the media library
messenger->deleteResource(&removeUrl, NULL, node.getDefaultUserId());
// pass even if there is an exception - this is meant to just clear any
// previous entries in the medialibrary database if they existed.
Exception::clear();
tr.group("customcatalog");
tr.test("add file to medialibrary (valid)");
{
DynamicObject in;
DynamicObject out;
// create a FileInfo object
string normalizedPath;
File::normalizePath(
(sTestDataDir + TEST_FILENAME_2).c_str(), normalizedPath);
out["path"] = normalizedPath.c_str();
out["mediaId"] = 2;
// prepare event waiter
EventWaiter ew(node.getEventController());
ew.start("bitmunk.medialibrary.File.updated");
ew.start("bitmunk.medialibrary.File.exception");
// add the file to the media library
assertNoException(
messenger->post(&filesUrl, &out, &in, node.getDefaultUserId()));
// wait for file ID set event
assert(ew.waitForEvent(5*1000));
// ensure it has an exception
Event e = ew.popEvent();
//dumpDynamicObject(e);
//.........这里部分代码省略.........
示例3: reprocessRequired
void DownloadStateEventReactor::reprocessRequired(Event& e)
{
// get user ID
UserId userId = BM_USER_ID(e["details"]["userId"]);
// ensure operation is done as the user to protect against logout
Operation op = mNode->currentOperation();
if(mNode->addUserOperation(userId, op, NULL))
{
// lock to prevent double-reprocessing download states
// Note: Reprocessing the download state isn't fatal, it just may fail
// silently or be annoying by re-assembling already assembled files, etc.
mReprocessLock.lock();
{
// log activity
MO_CAT_DEBUG(BM_EVENTREACTOR_DS_CAT,
"Event reactor handling ds 'reprocessRequired' "
"event for user %" PRIu64 "...", userId);
// get messenger
Messenger* messenger = mNode->getMessenger();
// process all queued directives
{
Url url;
url.format("%s/api/3.0/system/directives?nodeuser=%" PRIu64,
messenger->getSelfUrl(true).c_str(), userId);
DynamicObject directives;
if(messenger->get(&url, directives, userId))
{
DynamicObjectIterator i = directives.getIterator();
while(i->hasNext())
{
DynamicObject& directive = i->next();
// process the directive if it is of type "peerbuy":
if(strcmp(directive["type"]->getString(), "peerbuy") == 0)
{
url.format(
"%s/api/3.0/system/directives/process/%s?nodeuser=%"
PRIu64,
messenger->getSelfUrl(true).c_str(),
directive["id"]->getString(), userId);
DynamicObject in;
if(!messenger->post(&url, NULL, &in, userId))
{
// schedule exception event
Event e2;
e2["type"] =
"bitmunk.eventreactor.EventReactor.exception";
e2["details"]["exception"] =
Exception::getAsDynamicObject();
mNode->getEventController()->schedule(e2);
}
}
}
}
}
// create a list of download states to reprocess
DownloadStateList list;
list->setType(Array);
if(e["details"]->hasMember("all") && e["details"]["all"]->getBoolean())
{
// get all non-processing download states
Url url;
url.format("%s/api/3.0/purchase/contracts/downloadstates"
"?nodeuser=%" PRIu64 "&incomplete=true&processing=false",
messenger->getSelfUrl(true).c_str(), userId);
DynamicObject in;
if(messenger->get(&url, in, userId))
{
// append states to list
list.merge(in["downloadStates"], true);
}
else
{
// schedule exception event
Event e2;
e2["type"] = "bitmunk.eventreactor.EventReactor.exception";
e2["details"]["exception"] =
Exception::getAsDynamicObject();
mNode->getEventController()->schedule(e2);
}
}
else if(e["details"]->hasMember("downloadStateId"))
{
// reprocess single download state
DownloadStateId dsId = e["details"]["downloadStateId"]->getUInt64();
IPurchaseModule* ipm = dynamic_cast<IPurchaseModule*>(
mNode->getKernel()->getModuleApi(
"bitmunk.purchase.Purchase"));
DownloadState ds;
ds["id"] = dsId;
BM_ID_SET(ds["userId"], userId);
if(ipm->populateDownloadState(ds))
{
//.........这里部分代码省略.........