void ThingsMaintenance::onExecuteForGroupAction(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode, std::string mnt) { if (eCode != OC_STACK_OK) { std::cout << "onPut Response error: " << eCode << std::endl; getCallback(mnt)(headerOptions, rep, eCode); return ; } std::cout << "PUT request was successful" << std::endl; getCallback(mnt)(headerOptions, rep, eCode); // Delete the created actionset std::shared_ptr < OCResource > resource = getResource(mnt); if (resource) { g_groupmanager->deleteActionSet(resource, mnt, std::function< void(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode) >( std::bind(&ThingsMaintenance::onDeleteGroupAction, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, mnt))); } }
void ThingsMaintenance::onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode, std::string mnt) { if (eCode != OC_STACK_OK) { std::cout << "onPut Response error: " << eCode << std::endl; getCallback(mnt)(headerOptions, rep, eCode); return ; } std::cout << "PUT request was successful" << std::endl; getCallback(mnt)(headerOptions, rep, eCode); }
void WebGetter::update() { lock_guard<mutex>{m}; Connection::run(); auto it = sessions.begin(); while(it != sessions.end()) { auto s = *it; if(s->gotHeaders() && s->isRedirect()) { auto location = s->getHeader("Location"); if(!startsWith(location, "http://")) { location = format("http://%s:%d%s", s->getHost(), s->getPort(), urlencode(location, ":\\?;+ ")); } LOGD("Redirecting to '%s'", location); auto callback = s->getCallback(); it = sessions.erase(it); auto s = make_shared<HttpSession>(location); sessions.push_back(s); s->connect(); s->stream(callback); it = sessions.end(); continue; } if(s->error()) { errorCallback(0, ""); } if(s->done()) { it = sessions.erase(it); LOGD("Session done"); } else it++; } }
void SavePoints::callAndProcess() { SavePoint savepoint; // empty parameters // We ignore the kEntityPlayer callback in the list EntityIndex index = kEntityAnna; // Call all callbacks with empty parameters bool isRunning = getFlags()->isGameRunning; while (isRunning) { Entity::Callback *callback = getCallback(index); if (callback != NULL && callback->isValid()) { (*callback)(savepoint); isRunning = getFlags()->isGameRunning; } index = (EntityIndex)(index + 1); // Process all savepoints when done if (index >= 40) { if (isRunning) process(); return; } } }
void MultiTimer::stopTimer (const int timerID) noexcept { const SpinLock::ScopedLockType sl (timerListLock); if (Timer* const t = getCallback (timerID)) t->stopTimer(); }
/** * Socket associated with client connection has indicated it has data ready * to read. We want to determine which client connection and receive the data * from it. */ void Server::handleServerConnection(int sckt) { //determine connection ServerConnection* connection = mConnections->getServerConnection(sckt); if (0 != connection) { Callback* callback = getCallback(); try { //receive data std::vector<char> result = connection->performReceive(); if (0 != callback) { callback->receiveComplete(connection->getIdentifier(), &(result[0]), result.size()); } } catch (std::runtime_error) { if (0 != callback) { callback->disconnected(connection->getIdentifier()); } //error retrieving data from client, connection is bad, need to remove it mConnections->removeServerConnection(sckt); } } }
bool IniSetting::Get(const std::string& name, folly::dynamic& value) { auto cb = get_callback(name); if (!cb) { return false; } value = cb->getCallback(); return true; }
bool IniSetting::Get(const String& name, Variant& value) { auto cb = get_callback(name.toCppString()); if (!cb) { return false; } value = cb->getCallback(); return true; }
void AclEngine::Implementation::ChannelList::Channel::Receive::reportL2CapPacketEndedPrematurely() { CountedPointer<AclEngine::Callback> callback(getCallback()); if (callback) { callback->l2CapPacketEndedPrematurely(l2CapLengthRemaining); } }
int MultiTimer::getTimerInterval (const int timerID) const noexcept { const SpinLock::ScopedLockType sl (timerListLock); if (Timer* const t = getCallback (timerID)) return t->getTimerInterval(); return 0; }
bool MultiTimer::isTimerRunning (const int timerID) const noexcept { const SpinLock::ScopedLockType sl (timerListLock); if (Timer* const t = getCallback (timerID)) return t->isTimerRunning(); return false; }
void MultiTimer::startTimer (const int timerID, const int intervalInMilliseconds) noexcept { const SpinLock::ScopedLockType sl (timerListLock); Timer* timer = getCallback (timerID); if (timer == nullptr) timers.add (timer = new MultiTimerCallback (timerID, *this)); timer->startTimer (intervalInMilliseconds); }
std::string LastBoss::serialize(std::ostream &os) const { std::string sym = gensym(); os << sym << ":MAKE-LAST-BOSS " << stringify(getName()) << " " << stringify(getBaseDescription()) << " " << stats.serializeString() << " " << hp << " " << stringify(getCallback()) << std::endl; actorTypeIndependentSerialize(os, sym); return sym; }
std::string CallbackHuman::serialize(std::ostream &os) const { std::string sym = gensym(); os << sym << ":MAKE-CALLBACK-HUMAN " << stringify(getName()) << " " << stringify(getBaseDescription()) << " " << stats.serializeString() << " " << hp << " " << stringify(getCallback()) << std::endl; actorTypeIndependentSerialize(os, sym); return sym; }
void SavePoints::call(EntityIndex entity2, EntityIndex entity1, ActionIndex action, const char *param) const { SavePoint point; point.entity1 = entity1; point.action = action; point.entity2 = entity2; strcpy((char *)&point.param.charValue, param); Entity::Callback *callback = getCallback(entity1); if (callback != NULL && callback->isValid()) { debugC(8, kLastExpressDebugLogic, "Savepoint: entity1=%s, action=%s, entity2=%s, param=%s", ENTITY_NAME(entity1), ACTION_NAME(action), ENTITY_NAME(entity2), param); (*callback)(point); } }
void MessagesQueue::update(float dt) { for (Vector<Message>::iterator it = msgQueue.begin(); it != msgQueue.end();) { auto vec = mapListeners.at(it->mt); if (vec.size()) { for (auto vecIt = vec.begin(); vecIt != vec.end(); vecIt++) { auto a = vecIt->getCallback(); a(it->args); } } it = msgQueue.erase(it); } msgQueue.shrink_to_fit(); }
void onResult(const sp<Bundle>& data) { sp<ContextImpl> context = mContext.get(); if (context != nullptr) { bool result = data->getBoolean("result"); if (result) { sp<IBinder> binder = data->getBinder("binder"); mConn->onServiceConnected(mService->getComponent(), binder); } else { Log::e(ContextImpl::TAG, "Cannot bind to service %s", mService->getComponent()->toShortString()->c_str()); } context->mServiceConnectionCallbacks->remove(getCallback()); } }
// Process all savepoints void SavePoints::process() { while (_savepoints.size() > 0 && getFlags()->isGameRunning) { SavePoint savepoint = pop(); // If this is a data savepoint, update the entity // otherwise, execute the callback if (!updateEntityFromData(savepoint)) { // Call requested callback Entity::Callback *callback = getCallback(savepoint.entity1); if (callback && callback->isValid()) { debugC(8, kLastExpressDebugLogic, "Savepoint: entity1=%s, action=%s, entity2=%s", ENTITY_NAME(savepoint.entity1), ACTION_NAME(savepoint.action), ENTITY_NAME(savepoint.entity2)); (*callback)(savepoint); } } } }
//--------------------------------------------------------------------------- // beforeDeploy //--------------------------------------------------------------------------- void CConfigGenEngine::beforeDeploy() { m_installFiles.clear(); char tempPath[_MAX_PATH]; getTempPath(tempPath, sizeof(tempPath), m_name); m_envDepEngine.addTempDirectory( tempPath ); if (m_instances.ordinality() > 1) { strcat(tempPath, "Cache"); char* pszEnd = tempPath + strlen(tempPath); Owned<IFile> pFile = createIFile(tempPath); int i = 1; while (pFile->exists()) { //dir/file exists itoa(++i, pszEnd, 10); pFile.setown( createIFile(tempPath) ); } strcat(tempPath, PATHSEPSTR); m_cachePath.set( tempPath ); } else m_cachePath.set( tempPath ); ensurePath(tempPath); determineInstallFiles(m_process, m_installFiles); getCallback().installFileListChanged(); if (m_instances.ordinality() > 1) { EnvMachineOS os = m_envDepEngine.lookupMachineOS( m_instances.item(0) ); m_curInstance = "Cache"; copyInstallFiles("Cache", -1, tempPath, os); } }
void ThingsMaintenance::onGetChildInfoForUpdate(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode, std::string mnt) { if (eCode != OC_STACK_OK) { std::cout << "onGet Response error: " << eCode << std::endl; getCallback(mnt)(headerOptions, rep, eCode); return ; } std::cout << "GET request was successful" << std::endl; std::cout << "\tResource URI: " << rep.getUri() << std::endl; std::vector < OCRepresentation > children = rep.getChildren(); for (auto oit = children.begin(); oit != children.end(); ++oit) { std::cout << "\t\tChild Resource URI: " << oit->getUri() << std::endl; } // Get information by using maintenance name(mnt) std::shared_ptr < OCResource > resource = getResource(mnt); std::string actionstring = mnt; std::string uri = getUriByMaintenanceName(mnt); std::string attrKey = mnt; if (uri == "") return; if (resource) { // In this nest, we create a new action set of which name is the dignostics name. // Required information consists of a host address, URI, attribute key, and // attribute value. ActionSet *newActionSet = new ActionSet(); newActionSet->actionsetName = mnt; for (auto oit = children.begin(); oit != children.end(); ++oit) { Action *newAction = new Action(); // oit->getUri() includes a host address as well as URI. // We should split these to each other and only use the host address to create // a child resource's URI. Note that the collection resource and its child // resource are located in same host. newAction->target = getHostFromURI(oit->getUri()) + uri; Capability *newCapability = new Capability(); newCapability->capability = attrKey; newCapability->status = getUpdateVal(mnt); newAction->listOfCapability.push_back(newCapability); newActionSet->listOfAction.push_back(newAction); } // Request to create a new action set by using the above actionSet g_groupmanager->addActionSet(resource, newActionSet, std::function< void(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode) >( std::bind(&ThingsMaintenance::onCreateActionSet, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, mnt))); delete(newActionSet); } }
void Server::waitForEvents() throw (std::runtime_error) { //setup file descriptors fd_set masterRead; fd_set readFds; fd_set writeFds; FD_ZERO(&masterRead); FD_SET(mWakeupPipe[0], &masterRead); FD_SET(mConnectSocket->getSocket(), &masterRead); mConnections = new Connections(masterRead); int serverMax = std::max(mWakeupPipe[0], mConnectSocket->getSocket()); while (!mHasBeenShutdown) { int numfds = 0; int fdmax = std::max(serverMax, mConnections->getMax()); FD_ZERO(&readFds); FD_ZERO(&writeFds); //copy our master list of file descriptors readFds = masterRead; writeFds = mMasterWrite; /** * Select from specified file descriptors, will block */ numfds = select(fdmax + 1, &readFds, &writeFds, NULL, 0); if (-1 == numfds) { std::stringstream sstr; sstr << "select error " << strerror(errno); throw(std::runtime_error(sstr.str())); } if (mHasBeenShutdown) break; /** * Check all the file descriptors to see which were hit */ for (int i = 0; i <= fdmax; ++i) { if (FD_ISSET(i, &readFds)) //handle reads { /** * If connectSocket is ready, that means a connection is formed, any other * socket (per client connection) shows data is ready to be ready from a * client */ if (i == mConnectSocket->getSocket()) { //handle new connection try { ServerConnection* client = new ServerConnection( mConnectSocket->getSocket()); //performs accept, gets identifier getCallback()->connected(client->getIdentifier()); mConnections->addServerConnection(client); } catch (std::runtime_error& ex) { //TODO: log connection failure //std::cout << "failure: " << ex.what() << std::endl; } } else { //creating a new connection to a client handleServerConnection(i); } } /** * Self-pipe technique to wakeup and add additional file descriptors * to select set. */ if (FD_ISSET(mWakeupPipe[0], &readFds)) //performing wakeup { char buffer[1]; ::recv(mWakeupPipe[0], &mBuffer, sizeof(mBuffer), 0); } /** * See if we're ready to write to a client connection */ if (FD_ISSET(i, &writeFds)) { //ready for write ServerConnection* connection = mConnections->getServerConnection( i); if (0 != connection) { connection->sendQueuedMessage(getCallback()); } //write complete, clear it from the select list FD_CLR(i, &mMasterWrite); } } } }
AclEngine::Implementation::ChannelList::Channel::Receive::State AclEngine::Implementation::ChannelList::Channel::Receive::process(const HCIACL_L2CAP_PDU &pdu) { CountedPointer<AclEngine::Callback> callback(getCallback()); if (callback) { if (pdu.get_l2capLength() <= l2CapLengthRemaining) { if (!callback->receive(pdu, l2CapLengthRemaining)) { return callDefaultHandler(pdu); } l2CapLengthRemaining -= pdu.get_l2capLength(); if (l2CapLengthRemaining == 0) { return IDLE; } else { return PROCESSING; } } else { // Packet is too long. Split it in two, send first half to callback and second half to default handler. uint16 firstPacketLength; uint16 secondPacketLength; // Packet needs to be split in correct place, accounting for presence of l2cap header. switch(pdu.get_pbf()) { case HCIACLPDU::start: case HCIACLPDU::start_not_auto_flush: firstPacketLength = l2CapLengthRemaining + 4; break; default: firstPacketLength = l2CapLengthRemaining; break; } secondPacketLength = pdu.get_length() - firstPacketLength; const HCIACLPDU needed(pdu.get_dataPtr(), firstPacketLength, pdu.get_handle(), pdu.get_pbf(), pdu.get_bct()); const HCIACLPDU extra(pdu.get_dataPtr() + firstPacketLength, secondPacketLength, pdu.get_handle(), HCIACLPDU::cont, pdu.get_bct()); if (!callback->receive(needed, l2CapLengthRemaining)) { // Packet was rejected any way so send entire pdu to default handler l2CapLengthRemaining = 0; return callDefaultHandler(pdu); } else { l2CapLengthRemaining = 0; return callDefaultHandler(extra); } } } else { // Callback has been removed. Perhaps it was canceled return callDefaultHandler(pdu); } }
CONDITION SRV_CGetResponse(DUL_ASSOCIATIONKEY ** association, DUL_ASSOCIATESERVICEPARAMETERS * params, DUL_PRESENTATIONCONTEXT * getPresentationCtx, MSG_C_GET_REQ ** getRequest, MSG_C_GET_RESP * getResponse, SRV_C_GET_RESP_CALLBACK * getCallback, void *getCtx, char *dirName) { int flag, responseCount = 0; U32 l; char queryLevelString[48] = ""; /* Initialization for AIX compiler */ CONDITION cond, rtnCond = SRV_NORMAL; DCM_OBJECT * responseObject; /* get response object */ void *ctx; DCM_ELEMENT queryLevelElement = {DCM_IDQUERYLEVEL, DCM_CS, "", 1, sizeof(queryLevelString), NULL}; static char *allowedQueryLevels[] = { DCM_QUERYLEVELPATIENT, DCM_QUERYLEVELSTUDY, DCM_QUERYLEVELSERIES, DCM_QUERYLEVELIMAGE}; MSG_STATUS_DESCRIPTION statusDescription; char pendingMsg[] = "\ In SRV_CGetResponse, the response message returned by your callback has \n\ a status of pending and data set that is not null.\n"; MSG_TYPE messageType; void *message; DUL_PRESENTATIONCONTEXTID ctxID; MSG_C_STORE_REQ storeRequest; char classUID[DICOM_UI_LENGTH + 1]; queryLevelElement.d.string = queryLevelString; if (getCallback == NULL) { (void) MSG_Free((void **) getRequest); return COND_PushCondition(SRV_NOCALLBACK, SRV_Message(SRV_NOCALLBACK), "SRV_CGetResponse"); } if (getResponse->type != MSG_K_C_GET_RESP) { (void) MSG_Free((void **) getRequest); return COND_PushCondition(SRV_ILLEGALPARAMETER, SRV_Message(SRV_ILLEGALPARAMETER), "type", "GET Request", "SRV_CGetResponse"); } (void) strcpy(classUID, (*getRequest)->classUID); cond = DCM_CreateObject(&getResponse->identifier, 0); if (cond != DCM_NORMAL) return COND_PushCondition(SRV_RESPONSEFAILED, SRV_Message(SRV_RESPONSEFAILED), "SRV_CGetResponse"); cond = SRV_ReceiveDataSet(association, getPresentationCtx, DUL_BLOCK, 0, dirName, &(*getRequest)->identifier); if (PRVSRV_debug && (cond == SRV_NORMAL)) (void) DCM_DumpElements(&(*getRequest)->identifier, 0); if (cond != SRV_NORMAL) { (void) MSG_Free((void **) getRequest); return COND_PushCondition(SRV_RESPONSEFAILED, SRV_Message(SRV_RESPONSEFAILED), "SRV_CGetResponse"); } ctx = NULL; cond = DCM_GetElementValue(&(*getRequest)->identifier, &queryLevelElement, &l, &ctx); if (cond != DCM_NORMAL) { (void) MSG_Free((void **) getRequest); (void) COND_PushCondition(SRV_QUERYLEVELATTRIBUTEMISSING, SRV_Message(SRV_QUERYLEVELATTRIBUTEMISSING), "SRV_CGetResponse"); return COND_PushCondition(SRV_RESPONSEFAILED, SRV_Message(SRV_RESPONSEFAILED), "SRV_CGetResponse"); } queryLevelString[l] = '\0'; if (queryLevelString[l - 1] == ' ') queryLevelString[l - 1] = '\0'; for (flag = 0, l = 0; l < DIM_OF(allowedQueryLevels) && !flag; l++){ if (strcmp(queryLevelString, allowedQueryLevels[l]) == 0) flag = 1; } if (!flag) { (void) MSG_Free((void **) getRequest); (void) COND_PushCondition(SRV_ILLEGALQUERYLEVELATTRIBUTE, SRV_Message(SRV_ILLEGALQUERYLEVELATTRIBUTE), queryLevelString, "SRV_CGetResponse"); return COND_PushCondition(SRV_RESPONSEFAILED, SRV_Message(SRV_RESPONSEFAILED), "SRV_CGetResponse"); } getResponse->messageIDRespondedTo = (*getRequest)->messageID; getResponse->conditionalFields = 0; getResponse->remainingSubOperations = 0; getResponse->completedSubOperations = 0; getResponse->failedSubOperations = 0; getResponse->warningSubOperations = 0; /* * Fill up the Store request and let the callback routine do the matching * and fill the rest of the fields */ storeRequest.type = MSG_K_C_STORE_REQ; storeRequest.conditionalFields = 0; storeRequest.messageID = SRV_MessageIDOut(); storeRequest.priority = 0; storeRequest.moveMessageID = (*getRequest)->messageID; /* * We invoke the callback for the first time without any StoreResponse so * that the callback can deal with the query and fill the Store Request * message and the GET response message. We also pass responseCount as 0 * when we invoke the callback for the first time */ cond = getCallback(*getRequest, getResponse, &storeRequest, NULL, 0, getPresentationCtx->abstractSyntax, queryLevelString, getCtx); if (cond != SRV_NORMAL) return COND_PushCondition(SRV_CALLBACKABORTEDSERVICE, SRV_Message(SRV_CALLBACKABORTEDSERVICE), "SRV_CGetRespose"); if (storeRequest.dataSetType != DCM_CMDDATANULL) { /* Send a Store Request */ cond = sendStoreRequest(association, params, &storeRequest); if (cond != SRV_NORMAL) return COND_PushCondition(SRV_SENDFAILED, SRV_Message(SRV_SENDFAILED),"sendStoreRequest", "SRV_CGetResponse"); }else{ /* * No images are to be transferred as the query may have been * unsuccessful in the call back routine. We expect the callback * routine to have supplied the appropriate values for the various * fields of the getResponse message. * * Send the CGetResponse Message and return from the routine */ cond = MSG_BuildCommand(getResponse, &responseObject); if (cond != MSG_NORMAL) return COND_PushCondition(SRV_OBJECTBUILDFAILED, SRV_Message(SRV_OBJECTBUILDFAILED), "getResponse", "SRV_CGetResponse"); cond = SRV_SendCommand(association, getPresentationCtx, &responseObject); if (cond != SRV_NORMAL) return COND_PushCondition(SRV_SENDFAILED, SRV_Message(SRV_SENDFAILED),"SRV_SendCommand", "SRV_CGetResponse"); if (getResponse->dataSetType != DCM_CMDDATANULL) { cond = SRV_SendDataSet(association, getPresentationCtx, &getResponse->identifier, NULL, NULL, 0); if (cond != SRV_NORMAL) return COND_PushCondition(SRV_SENDFAILED, SRV_Message(SRV_SENDFAILED), "SRV_SendDataSet", "SRV_CGetResponse"); } return SRV_NORMAL; } flag = 0; while (!flag) { /* * Now wait for incoming Store Responses or a Cancel Request. If it * is a Store Response, invoke the callback routine, with the Store * Response. The callback will update the Get Response message * accordingly and also fill the Store Request message if any more * requests are to be made */ cond = SRV_ReceiveCommand(association, params, DUL_BLOCK, 0, &ctxID, NULL, &messageType, (void **) &message); if (cond != SRV_NORMAL) return COND_PushCondition(SRV_RECEIVEFAILED, SRV_Message(SRV_RECEIVEFAILED), "SRV_CGetResponse"); switch (messageType) { case MSG_K_C_CANCEL_REQ: rtnCond = SRV_OPERATIONCANCELLED; getResponse->status = MSG_K_CANCEL; (void) MSG_Free(&message); cond = getCallback(*getRequest, getResponse, NULL, NULL, responseCount, getPresentationCtx->abstractSyntax, queryLevelString, getCtx); if (cond != SRV_NORMAL) return COND_PushCondition(SRV_CALLBACKABORTEDSERVICE, SRV_Message(SRV_CALLBACKABORTEDSERVICE), "SRV_CGetRespose"); getResponse->messageIDRespondedTo = (*getRequest)->messageID; break; case MSG_K_C_STORE_RESP: responseCount++; getResponse->dataSetType = DCM_CMDDATANULL; getResponse->status = 0xffff; /* * Fill up the Store request and let the callback routine do the * matching and fill the rest of the fields */ storeRequest.type = MSG_K_C_STORE_REQ; storeRequest.conditionalFields = 0; storeRequest.messageID = SRV_MessageIDOut(); storeRequest.priority = 0; storeRequest.moveMessageID = (*getRequest)->messageID; cond = getCallback(*getRequest, getResponse, &storeRequest, (MSG_C_STORE_RESP *) message, responseCount, getPresentationCtx->abstractSyntax, queryLevelString, getCtx); if (cond != SRV_NORMAL) return COND_PushCondition(SRV_CALLBACKABORTEDSERVICE, SRV_Message(SRV_CALLBACKABORTEDSERVICE), "SRV_CGetRespose"); if (storeRequest.dataSetType != DCM_CMDDATANULL) { /* make the next store request */ cond = sendStoreRequest(association, params, &storeRequest); if (cond != SRV_NORMAL) return COND_PushCondition(SRV_SENDFAILED, SRV_Message(SRV_SENDFAILED), "sendStoreRequest", "SRV_CGetResponse"); } break; default: break; } if (cond == SRV_NORMAL) { cond = MSG_StatusLookup(getResponse->status, MSG_K_C_GET_RESP, &statusDescription); if (cond != MSG_NORMAL) return COND_PushCondition(SRV_RESPONSEFAILED, SRV_Message(SRV_RESPONSEFAILED), "SRV_CGetResponse"); if (statusDescription.statusClass != MSG_K_CLASS_PENDING) flag = 1; /* Consistency check */ if ((statusDescription.statusClass == MSG_K_CLASS_PENDING) && (getResponse->dataSetType != DCM_CMDDATANULL)) { if (PRVSRV_debug) fprintf(DEBUG_DEVICE, pendingMsg); rtnCond = COND_PushCondition(SRV_SUSPICIOUSRESPONSE, SRV_Message(SRV_SUSPICIOUSRESPONSE), "C-GET", "pending", "not null", "SRV_CGetResponse"); } }else{ flag = 1; } strcpy(getResponse->classUID, classUID); getResponse->conditionalFields |= MSG_K_C_GETRESP_CLASSUID; cond = MSG_BuildCommand(getResponse, &responseObject); if (cond != MSG_NORMAL) { (void) MSG_Free((void **) getRequest); return COND_PushCondition(SRV_RESPONSEFAILED, SRV_Message(SRV_RESPONSEFAILED), "SRV_CGetResponse"); } cond = SRV_SendCommand(association, getPresentationCtx, &responseObject); if (cond != SRV_NORMAL) { (void) MSG_Free((void **) getRequest); return COND_PushCondition(SRV_RESPONSEFAILED, SRV_Message(SRV_RESPONSEFAILED), "SRV_CGetResponse"); } if (getResponse->dataSetType != DCM_CMDDATANULL) { cond = SRV_SendDataSet(association, getPresentationCtx, &getResponse->identifier, NULL, NULL, 0); if (cond != SRV_NORMAL) { (void) MSG_Free((void **) getRequest); return COND_PushCondition(SRV_RESPONSEFAILED, SRV_Message(SRV_RESPONSEFAILED), "SRV_CGetResponse"); } } } (void) MSG_Free((void **) getRequest); return rtnCond; }
////////////////////////////////////////////////////////////////////////// // update void SsChannelAL::update() { if( ALSource_ != 0 ) { // Capture AL source state. // Check state of source and change state depending. ALint ALState; alGetSourcei( ALSource_, AL_SOURCE_STATE, &ALState ); alBreakOnError(); // Handle our own internal state. switch( State_ ) { case ssCS_IDLE: { // Do nothing. return; } break; case ssCS_PREPARED: { // Trigger play. updateParams(); alSourcePlay( ALSource_ ); alBreakOnError(); // Perform callback. if( getCallback() != NULL ) { getCallback()->onStarted( this ); } State_ = ssCS_PLAYING; } break; case ssCS_PLAYING: { // Update channel. updateParams(); if( getCallback() != NULL ) { getCallback()->onPlaying( this ); } // Handle AL source state changes. switch( ALState ) { case AL_PLAYING: { State_ = ssCS_PLAYING; } break; case AL_PAUSED: { State_ = ssCS_PAUSED; } break; case AL_STOPPED: { State_ = ssCS_STOPPED; } break; } } break; case ssCS_PAUSED: { // Handle AL source state changes. switch( ALState ) { case AL_PLAYING: { State_ = ssCS_PLAYING; } break; case AL_PAUSED: { State_ = ssCS_PAUSED; } break; case AL_STOPPED: { State_ = ssCS_STOPPED; } break; } } break; case ssCS_STOPPED: { // Free sound if( getCallback() != NULL ) { getCallback()->onEnded( this ); } // Free channel. Parent_->freeChannel( this ); // Reset state to idle. State_ = ssCS_IDLE; } break; } /* Do we really need this? switch( ALState ) { case AL_INITIAL: { } break; case AL_PLAYING: { updateParams(); if( getCallback() != NULL ) { getCallback()->onPlaying( this ); } } break; case AL_PAUSED: { // TODO: Nothing } break; case AL_STOPPED: { /* // Free sound if( getCallback() != NULL ) { getCallback()->onEnded( this ); } // Parent_->freeChannel( this ); } break; } */ } }
void turn_right() { getCallback(NULL)->turn_right(); }
void turn_left() { getCallback(NULL)->turn_left(); }
void move_forward() { getCallback(NULL)->move_forward(); }