bool xRedisClient::mget(const DBIArray &vdbi, const KEYS & keys, ReplyData& vDdata) { bool bRet = false; size_t n = vdbi.size(); if (n!=keys.size()) { return bRet; } DataItem item; DBIArray::const_iterator iter_dbi = vdbi.begin(); KEYS::const_iterator iter_key = keys.begin(); for (;iter_key!=keys.end();++iter_key, ++iter_dbi) { const RedisDBIdx& dbi = *iter_dbi; SETDEFAULTIOTYPE(SLAVE); const string &key = *iter_key; if (key.length()>0) { bool ret = command_string(*iter_dbi, item.str, "GET %s", key.c_str()); if (!ret) { item.type = REDIS_REPLY_NIL; item.str = ""; } else { item.type = REDIS_REPLY_STRING; bRet = true; } vDdata.push_back(item); } } return bRet; }
bool TunnelInterfaceRegTest::writeFile(ReplyData replyData, WFString fileName) { // Create the file, if file already exist data will be appended. FILE* pSaveFile = fopen(fileName.c_str(), "ab"); if (pSaveFile == NULL) { return false; } // Get the buffer for writing if (replyData.getData() != NULL) { // Write the buffer to the file fwrite(replyData.getData(), replyData.getSize(), 1, pSaveFile); fclose(pSaveFile); return true; } // No buffer, this should never happen fclose(pSaveFile); return false; }
void TunnelInterfaceRegTest::dataReceived(RequestID requestID, ReplyData replyData) { if(replyData.getTotalDataSize() == 0) { m_state = ERROR; setTestFailed("ReplyData did not contain any data"); } else { coreprintln("dataReceived!"); if(m_state == WEB_REQ) { bool res = writeFile(replyData, "webpage.txt"); if(!res) { m_state = ERROR; setTestFailed("Where not able to write to file"); } if(replyData.isComplete()) { WFString URL = "http://TMap/B;cat_vf_vodafoneshop.png"; AsynchronousStatus status = m_tunnelInterface.requestData(URL); m_state = PIC_REQ; if(status.getStatusCode() != OK) { m_state = ERROR; setTestFailed(status.getStatusMessage()); } } } else if(m_state == PIC_REQ) { bool res = writeFile(replyData, "picture.png"); if(!res) { m_state = ERROR; setTestFailed("Where not able to write to file"); } if(replyData.isComplete()) { m_state = DONE; setTestPassed(); } } } }
int32_t xRedisClient::GetReply(xRedisContext* ctx, ReplyData& vData) { //vData.clear(); //ReplyData(vData).swap(vData); redisReply *reply; RedisConn *pRedisConn = static_cast<RedisConn *>(ctx->conn); int32_t ret = redisGetReply(pRedisConn->getCtx(), (void**)&reply); if (0==ret) { for (size_t i = 0; i < reply->elements; i++) { DataItem item; item.type = reply->element[i]->type; item.str.assign(reply->element[i]->str, reply->element[i]->len); vData.push_back(item); } } RedisPool::FreeReply(reply); return ret; }