本文整理汇总了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;
}
}
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
}
示例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
{
}
}
}
}
示例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");
}
示例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());
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
示例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;
}
示例14: threadRequest
void * threadRequest(void * args)
{
int slaveSocket = (intptr_t) args;
processRequest(slaveSocket);
// Close socket
close( slaveSocket );
}
示例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;
}