コード例 #1
0
ファイル: mainstruct.cpp プロジェクト: sealeks/nsdavinci
 commandstruct::commandstruct(guidtype gid, indx tgid, indx grp, num64 val_b,
         num64 val_s, guidtype clid, tagtype tp) {
     guid_ = static_cast<unum64> (gid);
     tagid_ = static_cast<num64> (tgid);
     type(tp);
     clientid(clid);
     executed(false);
     group(grp);
     value_before<num64 > (val_b);
     value_set<num64 > (val_s);
     istext(false);
 }
コード例 #2
0
ファイル: mainstruct.cpp プロジェクト: sealeks/nsdavinci
 commandstruct::commandstruct(guidtype gid, indx tgid, indx grp, const std::string& vl,
         guidtype clid) {
     guid_ = static_cast<unum64> (gid);
     tagid_ = static_cast<num64> (tgid);
     clientid(clid);
     type(TYPE_TEXT);
     executed(false);
     group(grp);
     value_before<num64 > (0);
     value_set<num64 > (0);
     strvalue(vl);
     istext(true);
 }
コード例 #3
0
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
//
void CPolicyClientRequestHandler::DumpClientsL(RFileWriteStream& aFile)
	{
	// Lint seems to have some trouble identifying the TThreadId class.
	// Due to this, Lint will report several errors here that are incorrect.
	// These errors are disabled.
	/*lint -e10 -e1013 -e1055 -e746 -e747 */
	for(TInt i = iControlPolicyClients.Count() - 1; i >= 0; i--)
		{
		TPckgC<TThreadId> clientid(iControlPolicyClients[i]->iClientId.Id());
		aFile.WriteL(clientid);
		}
	/*lint +e10 +e1013 +e1055 +e746 +e747 */
	}
コード例 #4
0
ファイル: mainstruct.cpp プロジェクト: sealeks/nsdavinci
 void commandstruct::reset_commandstruct(const std::string& vl, guidtype clid) {
     istext(true);
     strvalue(vl);
     if (clid != NULL_CLIENT) clientid(clid);
     executed(false);
 }
コード例 #5
0
ファイル: mainstruct.cpp プロジェクト: sealeks/nsdavinci
 void commandstruct::reset_commandstruct(num64 val_s, guidtype clid) {
     value_set<num64 > (val_s);
     istext(false);
     if (clid != NULL_CLIENT) clientid(clid);
     executed(false);
 }
コード例 #6
0
ファイル: mycached.cpp プロジェクト: david-pp/tinyworld
void MyCacheWorker::run()
{
	LOG4CXX_INFO(logger, "[" << name_ << "] worker started");

	//  Tell backend we're ready for work
    socket_->send("READY", 5);

	while (!s_interrupted)
	{
		try 
		{
			//  Read and save all frames until we get an empty frame
	        //  In this example there is only 1 but it could be more
	       	zmq::message_t client_addr_msg;
	       	socket_->recv(&client_addr_msg);

	       	//  Empty Frame
	       	{
		       	zmq::message_t empty;
		       	socket_->recv(&empty);
	       	}
	  
	        //  Get request, send reply
	        zmq::message_t request;
	        socket_->recv(&request);

	        //std::cout << "Worker: " << (char*)request.data() << std::endl;

	        // Do the Request
	        std::string reply;
	    	uint64_t id = 0;
	    	uint8_t cmd = 0;
	    	std::string msgbody;
	    	std::string clientid((char*)client_addr_msg.data(), client_addr_msg.size());
	    	if (MyCache::parseBinMsg(request, id, cmd, msgbody))
	    	{
	    		#if 0
	    		LOG4CXX_INFO(logger, "[" << name_ << "] [" << clientid << "] " 
	    			<< (char)cmd << " : "
	    			<< id << " : " 
	    			<< msgbody.size());
	    		#endif

	    		MsgHandler* handler = MsgHandler::createByType(cmd);
				if (handler)
				{
					handler->worker = this;
					handler->doMsg(reply, msgbody);
					delete handler;
				}
	    	}
	    	else
	    	{
	    		LOG4CXX_WARN(logger, "[" << name_ << "] [" << clientid << "] " 
	    			<< (char)cmd << " : "
	    			<< id << " : parse msg failed");
	    	}

			//reply = "FUCKYOU";
			
			// Reply
			{
				zmq::message_t empty;
		        socket_->send(client_addr_msg, ZMQ_SNDMORE);
		        socket_->send(empty, ZMQ_SNDMORE);
		        
		        zmq::message_t replymsg;
		        MyCache::packBinMsg(replymsg, id, cmd, reply);
		        socket_->send(replymsg);
	    	}
		}
		catch(const std::exception& err)
		{
			LOG4CXX_ERROR(logger, "[" << name_ << "] worker error : " << err.what());
			break;
		}
	}

	LOG4CXX_INFO(logger, "[" << name_ << "] worker finished");

	delete this;
}