本文整理汇总了C++中Subscription类的典型用法代码示例。如果您正苦于以下问题:C++ Subscription类的具体用法?C++ Subscription怎么用?C++ Subscription使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Subscription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: acquireExistingSubscription
// implemented from callback interface
// =============================================================================================
void SubscriptionFactory::dataChange(
OpcUa_UInt32 clientSubscriptionHandle,
const UaDataNotifications& dataNotifications,
const UaDiagnosticInfos & diagnosticInfos)
{
logger_->debug("New data change event for subscription %d", clientSubscriptionHandle);
// acquire the subscription for which the event was meant:
Subscription* subscription = 0;
Status acquireStatus = acquireExistingSubscription(clientSubscriptionHandle, subscription);
if (acquireStatus.isGood())
{
// update the session state
subscription->dataChange(dataNotifications, diagnosticInfos);
// release the acquired session
releaseSubscription(subscription);
}
else
{
logger_->warning("Unknown ClientSubscriptionHandle, discarding notification!");
}
}
示例2:
DArray<uint16> * LocalNodeInfo::getSubscribingClients (Message *pMsg)
{
DArray<uint16> *pSubscribingClients = NULL;
uint16 j = 0;
_m.lock (314);
for (UInt32Hashtable<SubscriptionList>::Iterator i = _localSubscriptions.getAllElements(); !i.end(); i.nextElement()) {
PtrLList<Subscription> *pSubscriptions = i.getValue()->getSubscriptionWild (pMsg->getMessageHeader()->getGroupName());
// Get every subscribed group that matches with the message's group
if (pSubscriptions != NULL) {
for (Subscription *pSub = pSubscriptions->getFirst(); pSub != NULL; pSub = pSubscriptions->getNext()) {
if ((pSub->getSubscriptionType() == Subscription::GROUP_PREDICATE_SUBSCRIPTION) || pSub->matches(pMsg)) {
if (pSubscribingClients == NULL) {
pSubscribingClients = new DArray<uint16>();
}
bool bFound = false;
for (unsigned int k = 0; k < pSubscribingClients->size(); k++) {
if ((*pSubscribingClients)[k] == i.getKey()) {
bFound = true;
break;
}
}
if (!bFound) {
(*pSubscribingClients)[j] = i.getKey();
j++;
}
}
}
delete pSubscriptions;
pSubscriptions = NULL;
}
}
_m.unlock (314);
return pSubscribingClients;
}
示例3: ACE_DEBUG
void
Event_Channel::subscription_event (ACE_Message_Block *data)
{
Event *event = (Event *) data->rd_ptr ();
ACE_DEBUG ((LM_DEBUG,
"(%t) received a subscription with %d bytes from connection id %d\n",
event->header_.len_,
event->header_.connection_id_));
Subscription *subscription = (Subscription *) event->data_;
// Convert the subscription into host byte order so that we can
// access it directly without having to repeatedly muck with it...
subscription->decode ();
ACE_DEBUG ((LM_DEBUG,
"(%t) connection_id_ = %d, total_consumers_ = %d\n",
subscription->connection_id_,
subscription->total_consumers_));
for (ACE_INT32 i = 0;
i < subscription->total_consumers_;
i++)
ACE_DEBUG ((LM_DEBUG,
"(%t) consumers_[%d] = %d\n",
i,
subscription->consumers_[i]));
}
示例4: subs
void Receiver::execute(AsyncSession& session, bool /*isRetry*/)
{
SubscriptionManager subs(session);
subscription = subs.subscribe(*this, queue, settings);
subs.run();
if (settings.autoAck) {
subscription.accept(subscription.getUnaccepted());
}
}
示例5: CRC
void LocalNodeInfo::recomputeConsolidateSubsciptionList (void)
{
// TODO CHECK: I don't think the includes applies anymore, so I commented it
// In fact, even if the includes returns true,
// I still need to merge subscriptions in terms of priority, reliability, sequenced, etc
CRC * pCRC = new CRC();
pCRC->init();
for (StringHashtable<Subscription>::Iterator iterator = _consolidatedSubscriptions.getIterator(); !iterator.end(); iterator.nextElement()) {
pCRC->update ((const char *)iterator.getKey());
pCRC->update32 (iterator.getValue());
}
uint16 oldCRC = pCRC->getChecksum();
// Delete the current Consolidate Subscription List and compute a new one
_consolidatedSubscriptions.clear();
// For each client
for (UInt32Hashtable<SubscriptionList>::Iterator i = _localSubscriptions.getAllElements(); !i.end(); i.nextElement()) {
SubscriptionList *pSL = i.getValue();
if (pSL != NULL) {
// Get all its subscriptions
PtrLList<String> *pSubgroups = pSL->getAllSubscribedGroups();
for (String *pSubGroupName = pSubgroups->getFirst(); pSubGroupName != NULL; pSubGroupName = pSubgroups->getNext()) {
// For each group, get the subscription the client has
const char *pszGroupName = pSubGroupName->c_str();
Subscription *pClientSub = pSL->getSubscription (pszGroupName);
// And the subscription in the consolidate subscription list if any
Subscription *pSubInConsolidateList = _consolidatedSubscriptions.getSubscription (pszGroupName);
if (pSubInConsolidateList == NULL) {
_consolidatedSubscriptions.addSubscription (pszGroupName, pClientSub->clone());
}
else {
/*if (pClientSub->includes (pSubInConsolidateList)) {
_consolidatedSubscriptions.removeGroup (pszGroupName);
_consolidatedSubscriptions.addSubscription (pszGroupName, pClientSub->clone());
}
else {*/
pClientSub->merge (pSubInConsolidateList);
/*}*/
}
}
}
}
pCRC->reset();
for (StringHashtable<Subscription>::Iterator iterator = _consolidatedSubscriptions.getIterator(); !iterator.end(); iterator.nextElement()) {
pCRC->update ((const char *) iterator.getKey());
pCRC->update32 (iterator.getValue());
}
uint16 newCRC = pCRC->getChecksum();
if (oldCRC != newCRC) {
ui32SubscriptionStateSeqID++;
GroupSubscription *pSubscription = new GroupSubscription(); // Void subscription to respect method interface
_notifier.modifiedSubscriptionForPeer (_pszId, pSubscription);
}
}
示例6: retrieveNodeInfo
int TopologyWorldState::updateSubscriptionState (StringHashtable<SubscriptionList> *pSubscriptionsTable, StringHashtable<uint32> *pNodesTable)
{
// Updates the remote subscriptions with the pSubscriptionsTable and pNodesTable info
_m.lock (131);
for (StringHashtable<uint32>::Iterator iterator = pNodesTable->getAllElements(); !iterator.end(); iterator.nextElement()) {
if (0 != stricmp (_pDisService->getNodeId(), iterator.getKey())) {
RemoteNodeInfo * pRNI = (RemoteNodeInfo*) retrieveNodeInfo (iterator.getKey());
if (pRNI) {
uint32 *pui32RemoteSeqId = iterator.getValue();
uint32 *pui32LocalSeqId = _subscriptionStateTable.get (iterator.getKey());
if (!pui32LocalSeqId) {
pui32LocalSeqId = new uint32();
}
if ((*pui32RemoteSeqId) > (*pui32LocalSeqId)) {
pRNI->unsubscribeAll();
(*pui32LocalSeqId) = (*pui32RemoteSeqId);
_subscriptionStateTable.put (iterator.getKey(), pui32LocalSeqId);
continue;
}
}
}
pNodesTable->remove (iterator.getKey());
}
// Update _ui16SubscriptionStateCRC
_crc.reset();
for (StringHashtable<uint32>::Iterator iterator = _subscriptionStateTable.getAllElements(); !iterator.end(); iterator.nextElement()) {
_crc.update ((const char *) iterator.getKey());
_crc.update32 (iterator.getValue());
}
_ui16SubscriptionStateCRC = _crc.getChecksum();
for (StringHashtable<SubscriptionList>::Iterator subIterator = pSubscriptionsTable->getAllElements(); !subIterator.end(); subIterator.nextElement()) {
const char * nodeId = subIterator.getKey();
if (pNodesTable->get (nodeId) != NULL) {
SubscriptionList *pSubs = subIterator.getValue();
RemoteNodeInfo * pRNI = (RemoteNodeInfo*) retrieveNodeInfo (nodeId);
if (pRNI == NULL) {
_m.unlock (131);
return 0;
}
// Add subscriptions to pRNI
for (StringHashtable<Subscription>::Iterator i = pSubs->getIterator(); !i.end(); i.nextElement()) {
Subscription *pSub = i.getValue();
Subscription *pSubAux = pSub->clone();
pRNI->subscribe(i.getKey(), pSubAux);
}
SubscriptionList *pSubscriptions = pRNI->getRemoteSubscriptionsCopy();
sendSubscriptionStateMsg (pSubscriptions, nodeId, pNodesTable->get (nodeId));
}
}
delete pSubscriptionsTable;
pSubscriptionsTable = NULL;
delete pNodesTable;
pNodesTable = NULL;
_m.unlock (131);
return 0;
}
示例7: checkAndLogMsg
int TopologyWorldState::printWorldStateInfo (void)
{
// Prints information about local node, like subscriptions, alive neighbors, dead peers, etc
_m.lock (141);
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "=========================================================================\n");
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " PRINT WORLD STATE INFO\n");
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " Node id: %s\n", _pDisService->getNodeId());
if ((_pLocalNodeInfo->getConsolidatedSubscriptions())->getCount() == 0) {
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " No subscribed groups\n");
} else {
_pLocalNodeInfo->printAllSubscribedGroups();
// Print subscribing clients
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " SUBSCRIBING CLIENTS:\n");
DArray<uint16> *pSubClients = _pLocalNodeInfo->getAllSubscribingClients();
for (int j = 0; j <= pSubClients->getHighestIndex(); j++) {
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " SUB CLIENT N.%d:\n", (*pSubClients)[j]);
SubscriptionList *pSubsForClient = _pLocalNodeInfo->getSubscriptionListForClient ((*pSubClients)[j]);
_pLocalNodeInfo->releaseLocalNodeInfo();
if (pSubsForClient && pSubsForClient->getCount() != 0) {
for (StringHashtable<Subscription>::Iterator i = pSubsForClient->getIterator(); !i.end(); i.nextElement()) {
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " SUBSCRIPTION:\n");
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " groupname %s\n", i.getKey());
Subscription *pS = i.getValue();
pS->printInfo();
}
}
}
// Print local consolidated subscriptions
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " LOCAL CONSOLIDATED SUBSCRIPTIONS:\n");
SubscriptionList *pSubscriptions = _pLocalNodeInfo->getConsolidatedSubscriptions();
for (StringHashtable<Subscription>::Iterator i = pSubscriptions->getIterator(); !i.end(); i.nextElement()) {
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " SUBSCRIPTION:\n");
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " groupname %s\n", i.getKey());
Subscription *pS = i.getValue();
pS->printInfo();
}
}
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "-------------------------------------------------------------------------\n");
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " %d ACTIVE NEIGHBORS\n", _pLocalNodeInfo->getCount());
for (StringHashtable<Thing>::Iterator iNeighbors = _pLocalNodeInfo->getAllElements(); !iNeighbors.end(); iNeighbors.nextElement()) {
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "-------------------------------------------------------------------------\n");
RemoteNodeInfo *pRNI = (RemoteNodeInfo *) iNeighbors.getValue();
pRNI->printRemoteNodeInfo();
}
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "-------------------------------------------------------------------------\n");
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " %d DEAD PEERS\n", _deadPeers.getCount());
for (StringHashtable<RemoteNodeInfo>::Iterator iDead = _deadPeers.getAllElements(); !iDead.end(); iDead.nextElement()) {
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "-------------------------------------------------------------------------\n");
RemoteNodeInfo *pRNI = (RemoteNodeInfo *) iDead.getValue();
pRNI->printRemoteNodeInfo();
}
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "=========================================================================\n");
_m.unlock (141);
return 0;
}
示例8: getSubscriptionForClient
int LocalNodeInfo::addHistoryInternal (uint16 ui16ClientId, const char *pszGroupName, History *pHistory)
{
Subscription *pSubscription = getSubscriptionForClient (ui16ClientId, pszGroupName);
if (pSubscription == NULL) {
return -1;
}
if (pSubscription->getSubscriptionType() != Subscription::GROUP_SUBSCRIPTION) {
return -2;
}
return pSubscription->addHistory (pHistory);
}
示例9: main
int main(int argc, char* argv[])
{
SetupNames();
try
{
Environment::Initialize(Environment::Events);
Connection con("db", "usr", "pwd");
con.SetAutoCommit(true);
Statement st(con);
st.Execute("create table table1(code number)");
st.Execute("create table table2(str varchar2(10))");
Subscription sub;
sub.Register(con, "sub-00", Subscription::AllChanges, EventHandler, 5468, 0);
sub.Watch("select * from table1");
sub.Watch("select * from table2");
st.Execute("alter table table1 add price number");
WaitForEvents();
st.Execute("insert into table1 values(1, 10.5)");
st.Execute("insert into table2 values('shoes')");
WaitForEvents();
st.Execute("update table1 set price = 13.5 where code = 1");
st.Execute("delete from table2 ");
WaitForEvents();
st.Execute("drop table table1");
st.Execute("drop table table2");
WaitForEvents();
con.Close();
/* start remote instance */
Environment::StartDatabase("db", "sys_usr", "sys_pwd", Environment::StartForce, Environment::StartFull);
/* shutdown remote instance */
Environment::ShutdownDatabase("db", "sys_usr", "sys_pwd", Environment::ShutdownAbort, Environment::ShutdownFull);
WaitForDatabase();
sub.Unregister();
}
catch (std::exception &ex)
{
std::cout << ex.what() << std::endl;
}
Environment::Cleanup();
}
示例10: response
void usubRequest::operator()(const SubscriptionLib::UsubRequest& req){
UserConnection * user = Users::getInstance()->getUser(req.getLogin());
Subscription * subs = SubList::getInstance()->getSubscription(req.getSubId());
if(user!=NULL && subs!=NULL &&socket_==user->getsocket() && user->isContainsSubject(subs)){
user->removeSubject(subs);
subs->removeObserver(user);
SubscriptionLib::UsubResponse response(0, std::string("USubs operation was succeed"));
MsgSender::deliver(response, user->getsocket());
}else{;
SubscriptionLib::UsubResponse response(1, std::string("User is not authorized |subscription with specified id is not exist | user is not subscribe this subscription"));
MsgSender::deliver(response, socket_);
}
}
示例11: getOnDemandDataGroupName
int LocalNodeInfo::unsubscribe (uint16 ui16ClientId, const char *pszGroupName, uint16 ui16Tag)
{
char *pszOnDemandDataGroupName = getOnDemandDataGroupName (pszGroupName);
if (pszOnDemandDataGroupName == NULL) {
// The on-demand subscription group name could not be generated
return -1;
}
_m.lock (306);
SubscriptionList *pSL = _localSubscriptions.get (ui16ClientId);
int rc = 0;
if (pSL == NULL) {
rc = -2;
}
else {
Subscription *pSub = pSL->getSubscription (pszGroupName);
if (pSub == NULL) {
rc = -3;
}
else {
uint8 ui8SubscriptionType = pSub->getSubscriptionType();
if ((ui8SubscriptionType == Subscription::GROUP_SUBSCRIPTION) && (ui16Tag == 0)) {
if (pSL->removeGroup (pszGroupName)) {
rc = -4;
}
else {
if (pSL->removeGroup (pszOnDemandDataGroupName)) {
rc = -5;
}
}
}
else if ((ui8SubscriptionType == Subscription::GROUP_TAG_SUBSCRIPTION) && (ui16Tag != 0)) {
if (pSL->removeGroupTag (pszGroupName, ui16Tag)) {
rc = -6;
}
else {
if (pSL->removeGroupTag (pszOnDemandDataGroupName, ui16Tag)) {
rc = -7;
}
}
}
}
}
if (rc == 0) {
recomputeConsolidateSubsciptionList ();
}
free (pszOnDemandDataGroupName);
_m.unlock (306);
return rc;
}
示例12: switch
void RosterManager::handleSubscription( const Subscription& s10n )
{
if( !m_rosterListener )
return;
switch( s10n.subtype() )
{
case Subscription::Subscribe:
{
bool answer = m_rosterListener->handleSubscriptionRequest( s10n.from(), s10n.status() );
if( m_syncSubscribeReq )
{
ackSubscriptionRequest( s10n.from(), answer );
}
break;
}
case Subscription::Subscribed:
{
// Subscription p( Subscription::Subscribe, s10n.from().bareJID() );
// m_parent->send( p );
m_rosterListener->handleItemSubscribed( s10n.from() );
break;
}
case Subscription::Unsubscribe:
{
Subscription p( Subscription::Unsubscribed, s10n.from().bareJID() );
m_parent->send( p );
bool answer = m_rosterListener->handleUnsubscriptionRequest( s10n.from(), s10n.status() );
if( m_syncSubscribeReq && answer )
remove( s10n.from().bare() );
break;
}
case Subscription::Unsubscribed:
{
// Subscription p( Subscription::Unsubscribe, s10n.from().bareJID() );
// m_parent->send( p );
m_rosterListener->handleItemUnsubscribed( s10n.from() );
break;
}
default:
break;
}
}
示例13: isInHistory
bool LocalNodeInfo::isInHistory (uint16 ui16ClientId, Message *pMsg, uint32 ui32LatestMsgRcvdPerSender)
{
_m.lock (312);
SubscriptionList *pSL = _localSubscriptions.get (ui16ClientId);
if (pSL != NULL) {
Subscription *pS = pSL->getSubscription (pMsg->getMessageInfo()->getGroupName());
if (pS) {
bool bRet = pS->isInHistory (pMsg, ui32LatestMsgRcvdPerSender);
_m.unlock (312);
return bRet;
}
}
_m.unlock (312);
return false;
}
示例14: BSON
int SubscribeDB::getMaxVersion(const UtlString& uri) const
{
mongo::BSONObj query = BSON(Subscription::uri_fld() << uri.str());
mongo::ScopedDbConnection conn(_info.getConnectionString());
auto_ptr<mongo::DBClientCursor> pCursor = conn->query(_info.getNS(), query);
unsigned int value = 0;
while (pCursor.get() && pCursor->more())
{
Subscription row = pCursor->next();
if (value < row.version())
value = row.version();
}
conn.done();
return value;
}
示例15: switch
int LocalNodeInfo::addFilter (uint16 ui16ClientId, const char *pszGroupName, uint16 ui16Tag)
{
_m.lock (301);
SubscriptionList *pSL = _localSubscriptions.get (ui16ClientId);
if (pSL == NULL) {
_m.unlock (301);
return -1;
}
if (pSL->addFilterToGroup (pszGroupName, ui16Tag) != 0) {
_m.unlock (301);
return -2;
}
bool bAddFilter = true;
// I can add the filter to the ConsolidatedSubscriptions only if every client subscribing that group has the filter too
for (UInt32Hashtable<SubscriptionList>::Iterator i = _localSubscriptions.getAllElements(); !i.end(); i.nextElement()) {
SubscriptionList *pSL = i.getValue();
Subscription *pS = pSL->getSubscription(pszGroupName);
switch (pS->getSubscriptionType()) {
case Subscription::GROUP_SUBSCRIPTION: {
if (!((GroupSubscription *)pS)->hasFilter(ui16Tag)) {
bAddFilter = false;
break;
}
break;
}
case Subscription::GROUP_TAG_SUBSCRIPTION: {
if (((GroupTagSubscription *)pS)->hasTag(ui16Tag)) {
bAddFilter = false;
break;
}
break;
}
case Subscription::GROUP_PREDICATE_SUBSCRIPTION :
bAddFilter = false;
break;
}
}
if (bAddFilter) {
_consolidatedSubscriptions.addFilterToGroup (pszGroupName, ui16Tag);
}
_m.unlock (301);
return 0;
}