本文整理汇总了C++中Store::set_aor_data方法的典型用法代码示例。如果您正苦于以下问题:C++ Store::set_aor_data方法的具体用法?C++ Store::set_aor_data怎么用?C++ Store::set_aor_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Store
的用法示例。
在下文中一共展示了Store::set_aor_data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_test_simple
/// Test the server.
void MemcachedStoreTest::do_test_simple(Store& store)
{
AoR* aor_data1;
AoR::Bindings::const_iterator i1;
AoR::Bindings::const_iterator i2;
AoR::Binding* b1;
bool rc;
int now;
std::string s;
// Test sequence 2 - getting/setting/querying a single registration for a single AoR
// Test 2.2 - flush the server.
store.flush_all();
// Test 2.3 - get an initial empty AoR record and add a binding.
now = time(NULL);
aor_data1 = store.get_aor_data(std::string("[email protected]"));
ASSERT_TRUE(aor_data1 != NULL);
EXPECT_EQ(0u, aor_data1->bindings().size());
b1 = aor_data1->get_binding(std::string("urn:uuid:00000000-0000-0000-0000-b4dd32817622:1"));
b1->_uri = std::string("<sip:[email protected]:59934;transport=tcp;ob>");
b1->_cid = std::string("gfYHoZGaFaRNxhlV0WIwoS-f91NoJ2gq");
b1->_cseq = 17038;
b1->_expires = now + 300;
b1->_priority = 0;
b1->_params.push_back(std::make_pair("+sip.instance", "\"<urn:uuid:00000000-0000-0000-0000-b4dd32817622>\""));
b1->_params.push_back(std::make_pair("reg-id", "1"));
b1->_params.push_back(std::make_pair("+sip.ice", ""));
// Test 2.4 - add the AoR record to the server.
rc = store.set_aor_data(std::string("[email protected]"), aor_data1);
EXPECT_TRUE(rc);
delete aor_data1;
// Test 2.5 - get the AoR record from the server.
aor_data1 = store.get_aor_data(std::string("[email protected]"));
EXPECT_EQ(1u, aor_data1->bindings().size());
EXPECT_EQ(std::string("urn:uuid:00000000-0000-0000-0000-b4dd32817622:1"), aor_data1->bindings().begin()->first);
b1 = aor_data1->bindings().begin()->second;
EXPECT_EQ(std::string("<sip:[email protected]:59934;transport=tcp;ob>"), b1->_uri);
EXPECT_EQ(std::string("gfYHoZGaFaRNxhlV0WIwoS-f91NoJ2gq"), b1->_cid);
EXPECT_EQ(17038, b1->_cseq);
EXPECT_EQ(now + 300, b1->_expires);
EXPECT_EQ(0, b1->_priority);
// Test 2.6 - update AoR record at the server and check it.
b1->_cseq = 17039;
rc = store.set_aor_data(std::string("[email protected]"), aor_data1);
EXPECT_TRUE(rc);
delete aor_data1;
aor_data1 = store.get_aor_data(std::string("[email protected]"));
EXPECT_EQ(1u, aor_data1->bindings().size());
EXPECT_EQ(std::string("urn:uuid:00000000-0000-0000-0000-b4dd32817622:1"), aor_data1->bindings().begin()->first);
b1 = aor_data1->bindings().begin()->second;
EXPECT_EQ(std::string("<sip:[email protected]:59934;transport=tcp;ob>"), b1->_uri);
EXPECT_EQ(std::string("gfYHoZGaFaRNxhlV0WIwoS-f91NoJ2gq"), b1->_cid);
EXPECT_EQ(17039, b1->_cseq);
EXPECT_EQ(now + 300, b1->_expires);
EXPECT_EQ(0, b1->_priority);
// Test 2.7 - update AoR record again at the server and check it, this time using get_binding.
b1->_cseq = 17040;
rc = store.set_aor_data(std::string("[email protected]"), aor_data1);
EXPECT_TRUE(rc);
delete aor_data1;
aor_data1 = store.get_aor_data(std::string("[email protected]"));
EXPECT_EQ(1u, aor_data1->bindings().size());
b1 = aor_data1->get_binding(std::string("urn:uuid:00000000-0000-0000-0000-b4dd32817622:1"));
EXPECT_EQ(std::string("<sip:[email protected]:59934;transport=tcp;ob>"), b1->_uri);
EXPECT_EQ(std::string("gfYHoZGaFaRNxhlV0WIwoS-f91NoJ2gq"), b1->_cid);
EXPECT_EQ(17040, b1->_cseq);
EXPECT_EQ(now + 300, b1->_expires);
EXPECT_EQ(0, b1->_priority);
// Now check the maximum expiry is what we think.
int max_exp = store.expire_bindings(aor_data1, now + 299);
EXPECT_EQ(1u, aor_data1->bindings().size());
EXPECT_EQ(now + 300, max_exp);
// Now expire a binding by pretending the time is in the future.
max_exp = store.expire_bindings(aor_data1, now + 301);
EXPECT_EQ(0u, aor_data1->bindings().size());
EXPECT_EQ(now + 301, max_exp);
delete aor_data1;
}