当前位置: 首页>>代码示例>>C++>>正文


C++ processRequest函数代码示例

本文整理汇总了C++中processRequest函数的典型用法代码示例。如果您正苦于以下问题:C++ processRequest函数的具体用法?C++ processRequest怎么用?C++ processRequest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了processRequest函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: kDebug

bool ListCommand::greedyTrigger(const QString& inputText)
{
  kDebug() << "Triggering greedy " << inputText;

  QHash<CommandListElements::Element, VoiceInterfaceCommand*> adaption = getAdaption();

  QList<CommandListElements::Element> adaptionKeys = adaption.keys();
  foreach (const CommandListElements::Element& element, adaptionKeys) {
    QList<VoiceInterfaceCommand*> interfaceCommands = adaption.values(element);
    foreach (VoiceInterfaceCommand* command, interfaceCommands) {
      if (command->matches(0, inputText)) {
        switch (element) {
          case CommandListElements::Back: return processRequest(0);
          case CommandListElements::One: return processRequest(1);
          case CommandListElements::Two: return processRequest(2);
          case CommandListElements::Three: return processRequest(3);
          case CommandListElements::Four: return processRequest(4);
          case CommandListElements::Five: return processRequest(5);
          case CommandListElements::Six: return processRequest(6);
          case CommandListElements::Seven: return processRequest(7);
          case CommandListElements::Eight: return processRequest(8);
          case CommandListElements::Next: return processRequest(9);
          case CommandListElements::Cancel:
            clw->close();
            return true;
        }
      }

    }

  }
开发者ID:KDE,项目名称:simon,代码行数:31,代码来源:listcommand.cpp

示例2: allocateReqItem

bool RequestItemMgr_c::handleRequest(int nFd, TempMemBuffer_c& dataReceived)
{
    //MSG("[%d] data received from client, to analyze...\n", dataReceived.getLength());

    bool bRet = true;

    bool bNewRequester = false;

    RequestItem_c* pReqItem = htRequestItems_m.lookup(nFd);
    if (NULL == pReqItem)
    {
        pReqItem = allocateReqItem();
        if (NULL == pReqItem)
        {
            return false;
        }

        pReqItem->setSocketFd(nFd);
        bNewRequester = true;

        // insert into hash table
        htRequestItems_m.insert(pReqItem->getFdAddress(), pReqItem);
    }


    if (!bNewRequester)
    {
        pReqItem->appendBuffer(dataReceived.getBuffer(), dataReceived.getLength());
        if (TlvParser_c::isMessageCompleted(pReqItem->getRequest(), pReqItem->getLength()))
        {
            bRet= processRequest(pReqItem, pReqItem->getRequest(), pReqItem->getLength());

            pReqItem->releaseBuffer();
        }
    }
    else
    {
        if (TlvParser_c::isMessageCompleted(dataReceived.getBuffer(), dataReceived.getLength()))
        {
            bRet = processRequest(pReqItem, dataReceived.getBuffer(), dataReceived.getLength());

            pReqItem->releaseBuffer();
        }
        else
        {
            pReqItem->appendBuffer(dataReceived.getBuffer(), dataReceived.getLength());
        }
    }

    return bRet;
}
开发者ID:anjian,项目名称:xprj-server,代码行数:51,代码来源:RequestItemMgr.cpp

示例3: threadPool

void * threadPool(void * socket)
{
	int masterSocket = (intptr_t) socket;
	
	
	while( 1 )
	{
	
		
		sem_wait(&sema);
		
		struct sockaddr_in clientIPAddressThread;
		int alenThread = 0;
	
		int slaveSocket = accept( masterSocket, (struct sockaddr *)&clientIPAddressThread, (socklen_t*)&alenThread);
		
		
		if ( slaveSocket < 0 ) 
		{
			perror( "accept" );
			exit( -1 );
		}
		
	
		// Process request.
		processRequest( slaveSocket );	
		
	
		// Close socket
		close( slaveSocket );

		sem_post(&sema);
		
	}
}
开发者ID:commshare,项目名称:Small-HTTP-Server,代码行数:35,代码来源:myhttpd.cpp

示例4: LOG_STRM_INFO

bool RosterItemExchange::stanzaReadWrite(int AHandleId, const Jid &AStreamJid, Stanza &AStanza, bool &AAccept)
{
	if (FSHIExchangeRequest==AHandleId && !AStanza.isError())
	{
		QDomElement xElem = AStanza.firstElement("x",NS_ROSTERX);
		if (!xElem.isNull() && !xElem.firstChildElement("item").isNull())
		{
			AAccept = true;

			LOG_STRM_INFO(AStreamJid,QString("Roster exchange request received, from=%1, kind=%2, id=%3").arg(AStanza.from(),AStanza.kind(),AStanza.id()));

			IRosterExchangeRequest request;
			request.streamJid = AStreamJid;
			request.contactJid = AStanza.from();
			request.id = AStanza.kind()==STANZA_KIND_IQ ? AStanza.id() : QString::null;
			request.message = AStanza.kind()==STANZA_KIND_MESSAGE ? Message(AStanza).body() : QString::null;

			QList<Jid> existItems;
			QDomElement itemElem = xElem.firstChildElement("item");

			bool isItemsValid = true;
			while (isItemsValid && !itemElem.isNull())
			{
				IRosterExchangeItem item;
				item.itemJid = Jid(itemElem.attribute("jid")).bare();
				item.name = itemElem.attribute("name");
				item.action = itemElem.attribute("action",ROSTEREXCHANGE_ACTION_ADD);

				QDomElement groupElem = itemElem.firstChildElement("group");
				while(!groupElem.isNull())
				{
					item.groups += groupElem.text();
					groupElem = groupElem.nextSiblingElement("group");
				}

				if (item.itemJid.isValid() && !existItems.contains(item.itemJid) && 
					(item.action==ROSTEREXCHANGE_ACTION_ADD || item.action==ROSTEREXCHANGE_ACTION_DELETE || item.action==ROSTEREXCHANGE_ACTION_MODIFY))
				{
					request.items.append(item);
					existItems.append(item.itemJid);
				}
				else
				{
					isItemsValid = false;
					LOG_STRM_WARNING(AStreamJid,QString("Failed to append roster exchange item, jid=%1, action=%2: Invalid item").arg(item.itemJid.bare(),item.action));
				}

				itemElem = itemElem.nextSiblingElement("item");
			}

			if (isItemsValid && !request.items.isEmpty())
				processRequest(request);
			else
				replyRequestError(request,XmppStanzaError::EC_BAD_REQUEST);

			return true;
		}
	}
	return false;
}
开发者ID:ChALkeR,项目名称:vacuum-im,代码行数:60,代码来源:rosteritemexchange.cpp

示例5: in

//SLOT : quand un message arrive, le récupère et le traite
void Server::receiveMessage()
{

    QTcpSocket *socket = qobject_cast<QTcpSocket *>(sender());
    if (socket == 0)
        return;

    QDataStream in(socket);

    while(1) {

        if (tailleMessage == 0) {
            if (socket->bytesAvailable() < (int)sizeof(tailleMessage))
                return;

            in >> tailleMessage;
        }

        if (socket->bytesAvailable() < tailleMessage)
            return;

        //récupère le message
        QString messageRecu;
        in >> messageRecu;


        qDebug() <<"Received message: " << messageRecu;
        processRequest(messageRecu,socket);

        // reset for the next message
        tailleMessage = 0;
    }
}
开发者ID:P0ppoff,项目名称:SmartProjector,代码行数:34,代码来源:server.cpp

示例6: while

void HistoryManager::loop()
{
    while(true)
    {
        boost::any polled = mpQueue->poll();

        if(!polled.empty())
        {
            if(polled.type() == typeid(spHistoryPack))
            {
                spHistoryPack sphp = boost::any_cast<spHistoryPack>(polled);
                processPack(sphp);
            }
            else if(polled.type() == typeid(spHistoryRequest))
            {
                spHistoryRequest request = boost::any_cast<spHistoryRequest>(polled);
                processRequest(request);
            }
            else if(polled.type() == typeid(LoginPackage))
            {
                LoginPackage loginPackage = boost::any_cast<LoginPackage>(polled);
                processLogin(loginPackage);
            }
            else
            {
            }

        }
    }
}
开发者ID:ntszar,项目名称:axg,代码行数:30,代码来源:historymanager.cpp

示例7: loop

void loop() {
  // NETWORKING
  // TODO FIGURE OUT WHETHRE THIS IS BLOCKING
  WiFiClient client = server.available();
  if (!client) return; // TODO CONTINUE LOOPING
  
  int timeout = COMM_TIMEOUT; // TODO LESS BUSY WAIT?
  logMsg("New client");
  while(!client.available() && --timeout>0) {
    delay(1);
  }
  if (timeout <= 0) {
    logMsg("TIMEOUT");
    client.flush();
    return;
  }
  
  // GET MSG
  // TODO FIGURE OUT WHY DOESN'T WORK DIRECTLY
  String str = client.readStringUntil(0);  
  client.flush();
  logMsg(String("Got message [") + str + "]");
  
  // SEND REPLY
  client.print(processRequest(str).toString());
  delay(1);
  logMsg("Client disonnected");
}
开发者ID:eggyolkmedia,项目名称:wifibox,代码行数:28,代码来源:box.cpp

示例8: ICMessageHandler

void ICServer::processPendingDatagrams()
{
    QByteArray datagram;
    QUdpSocket *socket = isRunning ? udpSocket : testUdpSocket;

    do {
        QHostAddress *address = new QHostAddress;
        datagram.resize(socket->pendingDatagramSize());
        socket->readDatagram(datagram.data(), datagram.size(), address);

        ICMessageHandler *messageHandler = new ICMessageHandler(this);
        connect(messageHandler, SIGNAL(connectionOffer(QString)), this, SLOT(processSidCollision(QString)));
        connect(messageHandler, SIGNAL(serverDiscovery(QHostAddress,QString)), this, SLOT(processDiscovery(QHostAddress,QString)));
        connect(messageHandler, SIGNAL(questionRequest(QHostAddress)), this, SLOT(processRequest(QHostAddress)));
        connect(messageHandler, SIGNAL(answerReady(ICAnswer,QString)), this, SLOT(processAnswer(ICAnswer,QString)));

        ICMessageProcessor *processor = new ICMessageProcessor(messageHandler, *address, datagram);

        QThreadPool::globalInstance()->start(processor);

        qDebug()<< "[1] Received from " << *address << datagram;

        delete address;
    } while (socket->hasPendingDatagrams());
}
开发者ID:hzzlzz,项目名称:InteractiveCourse,代码行数:25,代码来源:icserver.cpp

示例9: genCurl

QueryData genCurl(QueryContext& context) {
  QueryData results;

  auto requests = context.constraints["url"].getAll(EQUALS);
  auto user_agents = context.constraints["user_agent"].getAll(EQUALS);

  if (user_agents.size() > 1) {
    LOG(WARNING) << "Can only accept a single user_agent";
    return results;
  }

  // Using the like clause for urls wouldn't make sense
  if (context.constraints["url"].getAll(LIKE).size()) {
    LOG(WARNING) << "Using LIKE clause for url is not supported";
  }

  for (const auto& request : requests) {
    Row r;
    r["url"] = request;
    r["method"] = "GET";
    r["user_agent"] =
        user_agents.empty() ? kOsqueryUserAgent : *(user_agents.begin());

    auto status = processRequest(r);
    if (!status.ok()) {
      LOG(WARNING) << status.getMessage();
    }

    results.push_back(r);
  }

  return results;
}
开发者ID:chubbymaggie,项目名称:osquery,代码行数:33,代码来源:curl.cpp

示例10: main

int main(int argc, char **argv){
    
    char *conf, buf[MAXLINE];

    if (argc != 2) {
        fprintf(stderr, "Please Specify a Config File.");
        exit(0);
    }

    conf = argv[1];
    
    getConfig(conf);

    servers[0].fd = open_clientfd(servers[0].host, servers[0].port);
    servers[1].fd = open_clientfd(servers[1].host, servers[1].port);
    servers[2].fd = open_clientfd(servers[2].host, servers[2].port);
    servers[3].fd = open_clientfd(servers[3].host, servers[3].port);

    printf("Please Enter A Command: \n");

    while (fgets(buf, MAXLINE, stdin) != NULL) {
        // printf("The line was: %s\n", buf);
        processRequest(buf);
        printf("Please Enter a Command: \n");
    }

    close(servers[0].fd);
    close(servers[1].fd);
    close(servers[2].fd);
    close(servers[3].fd);

    exit(0);
}
开发者ID:jtresman,项目名称:networking,代码行数:33,代码来源:client.c

示例11: INFO_LOG

void ListenRISRequests::newRISRequest()
{
    QTcpSocket *tcpSocket = m_tcpRISServer->nextPendingConnection();
    QString risRequestData;

    INFO_LOG("Rebuda peticio de la IP " + tcpSocket->peerAddress().toString());
    if (tcpSocket->waitForReadyRead(TimeOutToReadData))
    {
        risRequestData = QString(tcpSocket->readAll());
        INFO_LOG("Dades rebudes: " + risRequestData);
    }
    else
    {
        INFO_LOG("No s'ha rebut dades, error: " + tcpSocket->errorString());
    }

    INFO_LOG("Tanco socket");
    tcpSocket->disconnectFromHost();
    INFO_LOG("Faig delete del socket");
    delete tcpSocket;

    if (!risRequestData.isEmpty())
    {
        processRequest(risRequestData);
    }
}
开发者ID:151706061,项目名称:starviewer,代码行数:26,代码来源:listenrisrequests.cpp

示例12: free

void *handleCall(void *ta)
{
    //int fd = *(int *)fdPointer;
    struct threadArguments *taPointer = (struct threadArguments *)ta;
    int fd = taPointer->fd;
    struct logInformation logInfo = taPointer->logInfo;
    free(ta);
    char request[BUFFERLENGTH];
    
    // read request
    FILE *inputStream = fdopen(fd, "r");
    fgets(request, BUFFERLENGTH, inputStream);
    //printf("Received a call on %d: request = %s", fd, request);
    skipRestOfHeader(inputStream);
    
    // process request
    processRequest(request, fd, &logInfo);
    
    fclose(inputStream);
    
    // clean up the memory allocated for the log strings
    //free(logInfo.IPaddress);
    //free(logInfo.timeRequestReceived);
    free(logInfo.quotedFirstLineOfRequest);
}
开发者ID:GradientVector,项目名称:CSC-4304---Unix-Systems-Programming,代码行数:25,代码来源:project2.c

示例13: while

	integer ServiceApp::pumpMessages()
	{
/*		if(instance->takeOwnership() == false)
			return -1;*/

		timeout = naturalNull;
		bool go_on = true;
		while(go_on){
			try {
				natural counter = 0;
				bool request = instance->anyRequest();
				while(!request && onIdle(counter)){
					counter++;
					request = instance->anyRequest();
				}
				const void *req = instance->waitForRequest(timeout);
				if(req){
					go_on = processRequest(req);
				} else {
					go_on = !stopCommand;
				}
			}
			catch(const Exception & e){
				onWaitException(e);
			}
		}

		return 0;
	}
开发者ID:ondra-novak,项目名称:lightspeed,代码行数:29,代码来源:serviceapp.cpp

示例14: threadRequest

void * threadRequest(void * args)
{
	int slaveSocket = (intptr_t) args;
	processRequest(slaveSocket);
	
	// Close socket
	close( slaveSocket );
}
开发者ID:commshare,项目名称:Small-HTTP-Server,代码行数:8,代码来源:myhttpd.cpp

示例15: serverRead

int serverRead(event *ev, int fd) {
	lookup_log(LOG_DEBUG, "read\n");
	int read = 0;
	char buf[IO_PACKET_SIZE];

	if (ev->wr_pos == 0) {
		read = anetRead(fd, &buf[0], PROTOCOL_HAEDER_SIZE);
		if (read == 0 && errno == ECONNRESET) {
free_conn:
			ev->wr_pos = 0;
			del_event(pool, fd);	
			close(fd);
			zfree(ev->data);
			lookup_log(LOG_DEBUG, "close fd\n");
			return 0;
		}
		ev->data = parse_protocol_header(buf);
	} else {
		int block = (ev->data->body_len + PROTOCOL_HAEDER_SIZE - ev->wr_pos) 
			/ IO_PACKET_SIZE;
		if (block > 0) {
			read = anetRead(fd, &buf[0], IO_PACKET_SIZE);			
		} else {
			read = anetRead(fd, &buf[0], 
				(ev->data->body_len + PROTOCOL_HAEDER_SIZE - ev->wr_pos) % IO_PACKET_SIZE);			
		}
		if (read == 0 && errno == ECONNRESET) {
			goto free_conn;
		}
		if (ev->body_data == NULL) {
			ev->body_data_size = IO_PACKET_SIZE * 2;
			ev->body_data = (char *)zmalloc(ev->body_data_size);
			memcpy(ev->body_data + ev->body_data_wr_pos, buf, read);
			ev->body_data_wr_pos += read;
		} else {
			if ((ev->body_data_wr_pos + read) > ev->body_data_size) {
				//resize
				ev->body_data_size = ev->body_data_size * 2;
				ev->body_data = (char *)zrealloc(ev->body_data, 
					ev->body_data_size);
			}
			memcpy(ev->body_data + ev->body_data_wr_pos, buf, read);
			ev->body_data_wr_pos += read;
		}
	}
	if (read > 0) {
		ev->wr_pos += read;	
	}
	lookup_log(LOG_DEBUG, "pos:%d\n", ev->wr_pos);
	if (ev->wr_pos >= (ev->data->body_len +  PROTOCOL_HAEDER_SIZE)) {
		parse_protocol_body(ev->body_data, ev->data);
		ev->wr_pos = 0;
		processRequest((lookup_protocol *)ev->data);
		ev->cb = serverWrite;
		set_event(pool, fd, EPOLLOUT);
	}
	return 0;
}
开发者ID:wudikua,项目名称:lookup,代码行数:58,代码来源:server.c


注:本文中的processRequest函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。