// --------------------------------------------------------------------------- // CVpnSipObserver::RunL // --------------------------------------------------------------------------- // void CVpnSipObserver::RunL() { LOG_1( "CVpnSipObserver::RunL iStatus = %d", iStatus.Int()); if ( iStatus == KErrNone ) { TInt val = 0; // SIP Profile Server notified completion of SIP deregistration. TInt err = iSIPProperty.Get( KPSVpnSipUid, KVpnSipState, val ); if ( err == KErrNone && val == ESipDeregisterCompleted ) { // If SIP is deregistered, let the VPN Connection Agent to // proceed VPN session start. LOG_( "CVpnSipObserver::RunL SIP is deregistered. VPN Connection Agent continue with VPN start." ); iAgent.ProceedServiceStart(); } else { // Keep monitoring. Subscribe(); } } // Check if observer can be restarted. else if ( iStatus != KErrCancel && iStatus != KErrServerTerminated && iStatus != KErrNotSupported ) { // Keep monitoring. Subscribe(); } else { // Error. LOG_1( "CVpnSipObserver::RunL Unknown error situation, iStatus = %d", iStatus.Int() ); } }
END_TEST START_TEST (test_two_subscribers_and_push_event) { printf("\n-----test_two_subscribers_and_push_event start-----\n"); sentToCallback = NULL; sentToCallback2 = NULL; InitEventProcessor(); int16_t stakeholderId = RegisterStakeholder("teststakeholder"); eventSubscription_t subscription; subscription.stakeholderId = stakeholderId; subscription.eventType = EVENT_HEARTBEAT; subscription.callback = &test_callback; Subscribe(subscription); stakeholderId = RegisterStakeholder("teststakeholder2"); eventSubscription_t subscription2; subscription2.stakeholderId = stakeholderId; subscription2.callback = &test_callback2; subscription2.eventType = EVENT_HEARTBEAT; Subscribe(subscription2); struct timespec tms; clock_gettime(CLOCK_REALTIME, &tms); event_t* event = (event_t*)malloc(sizeof(event_t)); event->timeStamp = tms.tv_sec; event->prio = 123; event->sourceId = stakeholderId; event->eventType = EVENT_HEARTBEAT; event->payloadSize = 0; event->payload = NULL; printf("pushing eventdata ptr=%p, timeStamp=%d, prio=%d, sourceId=%d, eventType=%d, payloadSize=%d, *payload=%p\n", event, event->timeStamp, event->prio, event->sourceId, event->eventType, event->payloadSize, event->payload); int rsp = PushEvent(event); printf("Done with PushEvent, moving on to asserts, waiting for callbacks to be called\n"); fflush(stdout); int waitForCallback = WaitForCallback(); ck_assert_int_eq (waitForCallback, 0); int waitForCallback2 = WaitForCallback2(); ck_assert_int_eq (waitForCallback2, 0); ck_assert_int_eq (rsp, EP_OK); printf("sentToCallback=%p sentToCallback2=%p\n", sentToCallback, sentToCallback2); ck_assert_ptr_ne (sentToCallback, (event_t*)0); ck_assert_ptr_ne (sentToCallback2, (event_t*)0); if ((sentToCallback - sentToCallback2) == 0) ck_abort_msg("Failed! Same event sent to both subscribers"); int firstEventEqual = CompareEvent(event, sentToCallback); ck_assert_int_eq (firstEventEqual, 0); int secondEventEqual = CompareEvent(event, sentToCallback2); ck_assert_int_eq (secondEventEqual, 0); printf("-----test_two_subscribers_and_push_event done-----\n\n"); free(event); }
bool LogCommandParser::OnCommand(const char *command, unsigned numParameters, char **parameterList, TransportInterface *transport, SystemAddress systemAddress, const char *originalString) { (void) originalString; if (strcmp(command, "Subscribe")==0) { unsigned channelIndex; if (numParameters==0) { Subscribe(systemAddress, 0); transport->Send(systemAddress, "Subscribed to all channels.\r\n"); } else if (numParameters==1) { if ((channelIndex=Subscribe(systemAddress, parameterList[0]))!=(unsigned)-1) { transport->Send(systemAddress, "You are now subscribed to channel %s.\r\n", channelNames[channelIndex]); } else { transport->Send(systemAddress, "Cannot find channel %s.\r\n", parameterList[0]); PrintChannels(systemAddress, transport); } } else { transport->Send(systemAddress, "Subscribe takes either 0 or 1 parameters.\r\n"); } } else if (strcmp(command, "Unsubscribe")==0) { unsigned channelIndex; if (numParameters==0) { Unsubscribe(systemAddress, 0); transport->Send(systemAddress, "Unsubscribed from all channels.\r\n"); } else if (numParameters==1) { if ((channelIndex=Unsubscribe(systemAddress, parameterList[0]))!=(unsigned)-1) { transport->Send(systemAddress, "You are now unsubscribed from channel %s.\r\n", channelNames[channelIndex]); } else { transport->Send(systemAddress, "Cannot find channel %s.\r\n", parameterList[0]); PrintChannels(systemAddress, transport); } } else { transport->Send(systemAddress, "Unsubscribe takes either 0 or 1 parameters.\r\n"); } } return true; }
ChatManager::ChatManager() : nextChannelID(2) { Subscribe(&ChatManager::HandleChannelJoinMessage, MSGTYPE_CHANNEL_JOIN, REQUIRE_ANY_CLIENT); Subscribe(&ChatManager::HandleChannelLeaveMessage, MSGTYPE_CHANNEL_LEAVE, REQUIRE_ANY_CLIENT); Subscribe(&ChatManager::HandleChatMessage, MSGTYPE_CHAT, REQUIRE_ACTOR | REQUIRE_ALIVE); Subscribe(&ChatManager::HandleCacheMessage, MSGTYPE_CACHEFILE, REQUIRE_READY_CLIENT); // Default channel channelIDs.PutUnique("gossip", 1); channelNames.PutUnique(1, "gossip"); }
SpawnManager::SpawnManager(psDatabase *db, CacheManager *cachemanager, EntityManager *entitymanager, GEMSupervisor *gemsupervisor) { database = db; cacheManager = cachemanager; entityManager = entitymanager; gem = gemsupervisor; //get a reference to the loot randomizer as we use it when making random loot items lootRandomizer = cachemanager->getLootRandomizer(); PreloadDatabase(); Subscribe(&SpawnManager::HandleLootItem, MSGTYPE_LOOTITEM, REQUIRE_READY_CLIENT | REQUIRE_ALIVE); Subscribe(&SpawnManager::HandleDeathEvent, MSGTYPE_DEATH_EVENT, NO_VALIDATION); }
void FProfilerClientManager::Unsubscribe() { #if STATS PendingSessionId.Invalidate(); Subscribe(PendingSessionId); #endif }
void CLimitedSubscriber::RunL() { Subscribe(); TBool limited; iProperty.Get(limited); iParent.SetLimitedDiscoverableIfChangedL(limited); }
void CDeviceNameSubscriber::RunL() { Subscribe(); // The P&S value is in Unicode for the convenience of clients ... TBuf16<KHCILocalDeviceNameMaxLength> unicodeName; iProperty.Get(unicodeName); // ... but the BT spec requires the device name in UTF-8 so do the conversion here: TBuf8<KHCILocalDeviceNameMaxLength> utf8Name; TInt ret = CnvUtfConverter::ConvertFromUnicodeToUtf8(utf8Name, unicodeName); // ret should never be > 0 since unicodeName is the same size as utf8Name hence we // shouldn't have any unconverted chars left over. if (ret == KErrNone) { iParent.SetLocalDeviceName(utf8Name); } else { // Set the P&S key with the old value so that clients can figure out their set failed. TBuf16<KHCILocalDeviceNameMaxLength> oldUnicodeName; RProperty::Get(KPropertyUidBluetoothCategory, KPropertyKeyBluetoothGetDeviceName, oldUnicodeName); RProperty::Set(KPropertyUidBluetoothCategory, KPropertyKeyBluetoothGetDeviceName, oldUnicodeName); } }
void CDeviceClassSubscriber::RunL() { Subscribe(); TInt cod; iProperty.Get(cod); iParent.SetDeviceClassL(static_cast<TUint32>(cod)); }
// --------------------------------------------------------------------------- // From class CActive // --------------------------------------------------------------------------- // void CTactilePropertyWatcher::RunL() { if ( iStatus.Int() == KErrNone ) { // Subscribe first, then notify the observer that a property // has changed. Subscribe(); iObserver.PropertyChangedL( iCategory, iKey ); } else if ( iStatus.Int() == KErrNotFound ) { // We get here if a property gets deleted. We still need to subscribe // to it because it might get redefined later. Subscribe(); } }
void CTouchInput::ConstructL() { CActiveScheduler::Add( this ); User::LeaveIfError( iTouchInputState.Attach( KPSUidAknFep, KAknFepTouchInputActive ) ); iHeightWatcher = CHeightWatcher::NewL( *this, iObserver ); Subscribe(); }
void DataServer::SubscribeAll() { if (DWORD tmp = WaitForSingleObject(h_instrumentGeted, 10000) ) { switch (tmp) { case WAIT_TIMEOUT: dblog->PrintLog("获取合约超时", "error"); break; case 0: dblog->PrintLog("获取今日交易合约成功"); break; default: dblog->PrintLog("获取合约错误", "error"); break; } } set<string>::iterator iter; for (iter = insts.begin(); iter != insts.end(); ++iter) { Subscribe(iter->c_str()); } dblog->PrintLog("订阅所有合约成功"); }
void RosterMaintaner::HandleSubscribe(pugi::xml_node Node) { if(SubscribeHandler == nullptr) return; JID From(Node.attribute("from").value()); SubscribeCallback::Response SubscribeResponse = SubscribeHandler->OnSubscribe(From); if( SubscribeResponse == SubscribeCallback::Response::Reject ) return; pugi::xml_document doc; pugi::xml_node PresenceTag = doc.append_child("presence"); pugi::xml_node SubscribeTag = PresenceTag.append_child("subscribed"); SubscribeTag.append_attribute("to"); SubscribeTag.attribute("to").set_value(From.GetBareJID().c_str()); Uplink->WriteXMLToSocket(&doc); if(SubscribeResponse == SubscribeCallback::Response::Allow) return; Subscribe(From); }
END_TEST START_TEST (test_subscribe_and_push_event) { printf("\n-----test_subscribe_and_push_event start-----\n"); InitEventProcessor(); int16_t stakeholderId = RegisterStakeholder("teststakeholder"); eventSubscription_t subscription; subscription.stakeholderId = stakeholderId; subscription.eventType = EVENT_HEARTBEAT; subscription.callback = test_callback; Subscribe(subscription); struct timespec tms; clock_gettime(CLOCK_REALTIME, &tms); event_t* event = (event_t*)malloc(sizeof(event_t)); event->timeStamp = tms.tv_sec; event->prio = 123; event->sourceId = stakeholderId; event->eventType = EVENT_HEARTBEAT; event->payloadSize = 0; event->payload = NULL; int rsp = PushEvent(event); int result = WaitForCallback(); ck_assert_int_eq (result, 0); ck_assert_int_eq (rsp, EP_OK); ck_assert_ptr_ne (sentToCallback, (event_t*)0); int equality = CompareEvent(event, sentToCallback); ck_assert_int_eq (equality, 0); free(event); printf("-----test_subscribe_and_push_event done-----\n\n"); }
/** Location update @param aPosition Position info from the data bus @param aStatus status of the bus @param aError error code @param aActualTime position update time */ void CNETResponseHandler::DataUpdate(TPositionInfo& aPosition, TInt aStatus, TInt aError, TTime aActualTime, TUint /* aAttributes */, TUint /*aMode*/) { LBSLOG(ELogP1, "CNETResponseHandler::DataUpdate Start "); Subscribe(); if(aStatus==KErrNone) { if((KErrNone == aError)) { LBSLOG(ELogP1, "CNETResponseHandler::DataUpdate Valid "); TLocationUpdate call(aPosition, aError, aActualTime, 0); iPositionerQ->PositionerIterator(call); iRequestHandler->NotifyRequestComplete(); } else if (aError < 0) { LBSLOG2(ELogP1, "CNETResponseHandler::DataUpdate - Error: %d", aError); TUpdateFailed call(aError); iPositionerQ->PositionerIterator(call); iRequestHandler->NotifyRequestComplete(); } else { // 'Futile' is the only +ve error code we currently have, so this shouldn't happen __ASSERT_DEBUG(EFalse, User::Panic(KAdaptationPanicCategory, EPanicUnknownUpdateError)); } } LBSLOG(ELogP1, "CNETResponseHandler::DataUpdate End "); }
CombatManager::CombatManager(CacheManager* cachemanager, EntityManager* entitymanager) : pvp_region(NULL) { randomgen = psserver->rng; cacheManager = cachemanager; entityManager = entitymanager; calc_damage = psserver->GetMathScriptEngine()->FindScript("Calculate Damage"); calc_decay = psserver->GetMathScriptEngine()->FindScript("Calculate Decay"); if ( !calc_damage ) { Error1("Calculate Damage Script could not be found. Check the math_scripts DB table."); } else if ( !calc_decay ) { Error1("Calculate Decay Script could not be found. Check the math_scripts DB table."); } else { targetLocations.Push(PSCHARACTER_SLOT_HELM); targetLocations.Push(PSCHARACTER_SLOT_TORSO); targetLocations.Push(PSCHARACTER_SLOT_ARMS); targetLocations.Push(PSCHARACTER_SLOT_GLOVES); targetLocations.Push(PSCHARACTER_SLOT_LEGS); targetLocations.Push(PSCHARACTER_SLOT_BOOTS); } staminacombat = psserver->GetMathScriptEngine()->FindScript("StaminaCombat"); Subscribe(&CombatManager::HandleDeathEvent, MSGTYPE_DEATH_EVENT, NO_VALIDATION); }
END_TEST START_TEST (test_subscribe_preinit) { eventSubscription_t subscription; int rsp = Subscribe(subscription); ck_assert_int_eq(rsp, EP_ENOINIT); }
void Opal::Sip::EndPoint::unfetch (const std::string uri) { if (std::find (subscribed_uris.begin (), subscribed_uris.end (), uri) != subscribed_uris.end ()) { Subscribe (SIPSubscribe::Presence, 0, PString (uri.c_str ())); subscribed_uris.remove (uri); } }
bool Game::Create(int iServiceID, EDF *pOptions) { STACKTRACE Subscribe(iServiceID); return Request("game_create", pOptions); }
/** * @see CActive::RunError(TInt) */ TInt CTsBacksteppingActivation::RunError( TInt aError ) { if (KErrCancel != aError) { Subscribe(); } return KErrNone; }
TInt CABDataOwner::RunError(TInt aError) { __LOG2("ABDataOwner [0x%08x] Panic'd with error code %d", iID.iId, aError); Subscribe(); return KErrNone; }
bool Game::Join(int iServiceID, EDF *pOptions) { STACKTRACE Subscribe(iServiceID); return Request("game_join", pOptions); }
bool ProgressionManager::Initialize() { Subscribe(&ProgressionManager::HandleSkill, MSGTYPE_GUISKILL, REQUIRE_READY_CLIENT); Subscribe(&ProgressionManager::HandleDeathEvent, MSGTYPE_DEATH_EVENT, NO_VALIDATION); Subscribe(&ProgressionManager::HandleZPointEvent, MSGTYPE_ZPOINT_EVENT, REQUIRE_READY_CLIENT); Result result_affinitycategories(db->Select("SELECT * from char_create_affinity")); if ( result_affinitycategories.IsValid() ) { for ( unsigned int x = 0; x < result_affinitycategories.Count(); x++ ) { affinitycategories.Put( csString( result_affinitycategories[(unsigned long)x]["category"]).Downcase() , csString( result_affinitycategories[(unsigned long)x]["attribute"]).Downcase() ); } } return true; }
AdviceManager::AdviceManager(psDatabase *db) { advisors.Empty(); advisorPos = 0; database = db; Subscribe(&AdviceManager::HandleAdviceMessage,MSGTYPE_ADVICE,REQUIRE_READY_CLIENT); }
// ----------------------------------------------------------------------------- // CUpnpConnectionManagerNetworkEventProvider::ConstructL // Symbian 2nd phase constructor can leave. // ----------------------------------------------------------------------------- // void CUpnpConnectionManagerNetworkEventProvider::ConstructL() { if ( iSessionOwner ) { iConnectionManagerSession = new (ELeave) RUpnpConnectionManagerSession; User::LeaveIfError( iConnectionManagerSession->Connect() ); } CActiveScheduler::Add( this ); Subscribe(); }
already_AddRefed<Promise> PushManager::Subscribe(ErrorResult& aRv) { if (mImpl) { MOZ_ASSERT(NS_IsMainThread()); return mImpl->Subscribe(aRv); } return PerformSubscriptionActionFromWorker(SubscribeAction, aRv); }
// --------------------------------------------------------------------------- // second phased constructor // --------------------------------------------------------------------------- // void CVpnSipObserver::ConstructL() { // KVpnSipState P&S key is used for communication between VPN client // and SIP Profile Server regarding SIP de/re-registration. // KPSVpnSipUid is defined in a SIP System State Monitor plugin // (CSipVpnMonitorAo). User::LeaveIfError( iSIPProperty.Attach( KPSVpnSipUid, KVpnSipState ) ); // Start monitoring the P&S key. Subscribe(); }
END_TEST START_TEST (test_subscribe_missingstakeholderid) { InitEventProcessor(); eventSubscription_t subscription; subscription.eventType = EVENT_HEARTBEAT; subscription.callback = test_callback; int rsp = Subscribe(subscription); ck_assert_int_eq(rsp, EP_EINVALIDSUB); }
void CTouchInput::RunL() { Subscribe(); TInt value = 0; User::LeaveIfError( iTouchInputState.Get( value ) ); TBool temp = static_cast<TBool>( value ); if ( temp != iVisible ) { iVisible = temp; iObserver.VisibleChanged(); } }
void AgentSubscription::on_connect (int rc) { _logger->log("Subscribing for " + getName()); // Add all the corresponding subscriptions if (global_config.subscribe_topic_name == TOPIC_PATH) { for (PathList::iterator itr = _path_list.begin(); itr != _path_list.end(); itr++) { Subscribe(*itr); } } else if (global_config.subscribe_topic_name == TOPIC_INTERNAL_SUB_ID) { int total_handles = _system_subscription->getHandleCount(); for (int i = 0; i < total_handles; i++) { AgentConsolidatorSystemHandlePtr csh = _system_subscription->getHandle(i); id_idx_t isubid = csh->getInternalSubscriptionId(); Subscribe("/" + std::to_string(isubid)); } } }