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


C++ RpcClient类代码示例

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


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

示例1: main

int main(int argc, char *argv[]) {
  if (argc!=3) {
    fprintf(stderr,"Call as %s X Y\n", argv[0]);
    return 1;
  }

  Network yarp;
  Node node("/yarp_add_int_client");

  RpcClient client;
  if (!client.open("add_two_ints")) {
    fprintf(stderr,"Failed to open client\n");
    return 1;
  }

  Bottle msg, reply;
  msg.addInt(atoi(argv[1]));
  msg.addInt(atoi(argv[2]));
  if (!client.write(msg,reply)) {
    fprintf(stderr,"Failed to call service\n");
    return 1;
  }
  printf("Got %d\n", reply.get(0).asInt());

  return 0;
}
开发者ID:paulfitz,项目名称:robobo,代码行数:26,代码来源:add_int_client_v2.cpp

示例2: main

int main(int argc, char *argv[]) {
    if (argc<3) {
        fprintf(stderr, "Please supply (1) a port name for the client\n");
        fprintf(stderr, "              (2) a port name for the server\n");
        return 1;
    }

    Network yarp;
    const char *client_name = argv[1];
    const char *server_name = argv[2];

    RpcClient port;
    port.open(client_name);

    int ct = 0;
    while (true) {
	if (port.getOutputCount()==0) {
	  printf("Trying to connect to %s\n", server_name);
	  yarp.connect(client_name,server_name);
	} else {
	  Bottle cmd;
	  cmd.addString("COUNT");
	  cmd.addInt32(ct);
	  ct++;
	  printf("Sending message... %s\n", cmd.toString().c_str());
	  Bottle response;
	  port.write(cmd,response);
	  printf("Got response: %s\n", response.toString().c_str());
	}
	Time::delay(1);
    }
}
开发者ID:robotology,项目名称:yarp,代码行数:32,代码来源:rpc_client.cpp

示例3: main

int main(int argc, char *argv[]) {
    if (argc!=3) {
        fprintf(stderr,"Call as %s X Y\n", argv[0]);
        return 1;
    }

    Network yarp;
    RpcClient client;
    yarp_test::AddTwoInts example;
    client.promiseType(example.getType());

    if (!client.open("/[email protected]/yarp_add_int_client")) {
        fprintf(stderr,"Failed to open port\n");
        return 1;
    }

    yarp_test::AddTwoInts msg;
    yarp_test::AddTwoIntsReply reply;
    msg.a = atoi(argv[1]);
    msg.b = atoi(argv[2]);
    if (!client.write(msg,reply)) {
        fprintf(stderr,"Failed to call service\n");
        return 1;
    }
    printf("Got %d\n", (int)reply.sum);

    return 0;
}
开发者ID:BRKMYR,项目名称:yarp,代码行数:28,代码来源:add_int_client_v1b.cpp

示例4: StopMeteringData

// Sends stop metering to RPC Service
__int64 StopMeteringData(RPC_CLIENT_HANDLE RpcClientHandle) {
    RpcClient* client;
    if (RpcClientHandle == NULL) {
        return ERROR_INVALID_PARAMETER;
    }

    client = RetriveRpcClientFromHandle(RpcClientHandle);
    if (client == NULL) {
        return ERROR_INVALID_HANDLE;
    }

    return client->StopMetering();
}
开发者ID:EasonDongH,项目名称:Windows-universal-samples,代码行数:14,代码来源:RpcClientApi.cpp

示例5: SetSampleRate

// Updates sample rate of metering RPC Service
__int64 SetSampleRate(RPC_CLIENT_HANDLE RpcClientHandle, int rate) {
    RpcClient* client;
    if (RpcClientHandle == NULL) {
        return ERROR_INVALID_PARAMETER;
    }

    client = RetriveRpcClientFromHandle(RpcClientHandle);
    if (client == NULL) {
        return ERROR_INVALID_HANDLE;
    }

    return client->SetSampleRate(rate);
}
开发者ID:EasonDongH,项目名称:Windows-universal-samples,代码行数:14,代码来源:RpcClientApi.cpp

示例6: StartMeteringAndWaitForStop

// Starts metering service and blocks till metering is stopped
__int64 StartMeteringAndWaitForStop(RPC_CLIENT_HANDLE RpcClientHandle, __int64 samplePeriod) {
    RpcClient* client;
    if (RpcClientHandle == NULL) {
        return ERROR_INVALID_PARAMETER;
    } 

    client = RetriveRpcClientFromHandle(RpcClientHandle);
    if (client == NULL) {
        return ERROR_INVALID_HANDLE;
    }

    return client->StartMeteringAndWaitForStop(samplePeriod);
}
开发者ID:EasonDongH,项目名称:Windows-universal-samples,代码行数:14,代码来源:RpcClientApi.cpp

示例7: RpcClient

void RpcService::send(const std::string &name, rpcproto::rpc *msg)
{
	RpcClient *rc = 0;
	std::map<std::string, RpcClient *>::iterator it = rpc_client_map_.find(name);
	if (it == rpc_client_map_.end())
	{
		std::string host = svc::env()->get_server_value(name, "host");
		std::string port = svc::env()->get_server_value(name, "port");
		if (host == "" || port == "")
		{
			return;
		}
		std::string addr = "tcp://" + host + ":" + port;
		rc = new RpcClient(name, addr);
		rpc_client_map_[name] = rc;
	}
	else
	{
		rc = (*it).second;
	}
	std::string s;
	msg->SerializeToString(&s);
	rc->putq(s);
}
开发者ID:rocketxyf,项目名称:cppnet,代码行数:24,代码来源:rpc_service.cpp

示例8: send

 void send()
 {
     if (emotions.getOutputCount()>0)
     {
         Bottle cmd, reply;
         cmd.addVocab(Vocab::encode("set"));
         cmd.addVocab(Vocab::encode("mou"));
         cmd.addVocab(Vocab::encode(state.c_str()));
         emotions.write(cmd,reply);
     }
 }
开发者ID:francesco-romano,项目名称:icub-main,代码行数:11,代码来源:main.cpp

示例9: respond

    bool respond(const Bottle &command, Bottle &reply)
    {
        string cmd=command.get(0).asString().c_str();
        int ack=Vocab::encode("ack");
        int nack=Vocab::encode("nack");

        if (cmd=="clear")
        {
            LockGuard lg(mutex);
            contour.clear();
            floodPoints.clear();
            go=flood3d=flood=false;
            reply.addVocab(ack);
        }
        else if ((cmd=="go") || (cmd=="flood3d"))
        {
            if (portSFM.getOutputCount()==0)
                reply.addVocab(nack);
            else
            {
                LockGuard lg(mutex);
                if (cmd=="go")
                {
                    if (contour.size()>2)
                    {
                        flood=false;
                        go=true;
                        reply.addVocab(ack);
                    }
                    else
                        reply.addVocab(nack);
                }
                else if (cmd=="flood3d")
                {
                    if (command.size()>=2)
                        spatial_distance=command.get(1).asDouble();

                    contour.clear();
                    floodPoints.clear();
                    flood=false;
                    flood3d=true;
                    reply.addVocab(ack);
                }
            }
        }
        else if (cmd=="flood")
        {
            if (command.size()>=2)
                color_distance=command.get(1).asInt();

            contour.clear();
            floodPoints.clear();
            flood=true;
            reply.addVocab(ack);
        }
        else
            RFModule::respond(command,reply);

        return true;
    }
开发者ID:giuliavezzani,项目名称:ipopt-works,代码行数:60,代码来源:3d-points.cpp

示例10: updateSim

    void updateSim(const Vector &c_)
    {
        if ((c_.length()!=3) && (c_.length()!=4))
            return;

        Vector c=c_;        
        if (c.length()==3)
            c.push_back(1.0);
        c[3]=1.0;

        c=Tsim*c;

        Bottle cmd,reply;
        cmd.addString("world");
        cmd.addString("set");
        cmd.addString("ssph");

        // obj #
        cmd.addInt(1);

        // position
        cmd.addDouble(c[0]);
        cmd.addDouble(c[1]);
        cmd.addDouble(c[2]);

        simPort.write(cmd,reply);
    }
开发者ID:robotology,项目名称:haptic-devices,代码行数:27,代码来源:main.cpp

示例11: configure

    bool configure(ResourceFinder &rf)
    {
        rf1=rf;

        if(algorithm==1)
            loc5=new UnscentedParticleFilter();
        else
            loc5=new ScalingSeries();

        loc5->configure(rf1);
        state=0;
        meas_given=1;

        if(loc5->measurementsString!=1)
        {
            namePorts = rf.check("namePorts", Value("visual-localization"), "Getting module name").asString();
            portIn.open("/"+namePorts+"/pnt:i");
            rpcOut.open("/"+namePorts+"/toolFeat:rpc");

            meas_given=0;
        }

        cout<<"meas_given "<<meas_given<<endl;
        error_thres=loc5->error_thres;
        cout<<"thresconf "<<error_thres<<endl;

        rpcPort.open(("/"+namePorts+"/rpc").c_str());
        attach(rpcPort);

        delete loc5;

        return true;

    }
开发者ID:giuliavezzani,项目名称:experience2016,代码行数:34,代码来源:main.cpp

示例12: interruptModule

    bool interruptModule()
    {

        cout<<"Interrupt caught!"<<endl;
		cout<<endl;
		handlerPort.interrupt();
		objectsPort.interrupt();
        return true;
    }
开发者ID:tanismar,项目名称:merge-point-clouds,代码行数:9,代码来源:torsoDemo.cpp

示例13: configure

    void configure(ResourceFinder &rf)
    {
        string name=rf.find("name").asString().c_str();
        string robot=rf.find("robot").asString().c_str();
        emotions.open(("/"+name+"/emotions:o").c_str());

        state="sur";
        setRate(rf.check("period",Value(200)).asInt());
    }
开发者ID:francesco-romano,项目名称:icub-main,代码行数:9,代码来源:main.cpp

示例14: close

    bool close()
    {
        if(meas_given!=1)
        {
            portIn.close();
            rpcOut.close();
        }
        rpcPort.close();
        return true;

    }
开发者ID:giuliavezzani,项目名称:experience2016,代码行数:11,代码来源:main.cpp

示例15: interruptModule

 bool interruptModule()
 {
     portDispIn.interrupt();
     portDispOut.interrupt();
     portOutPoints.interrupt();
     portImgIn.interrupt();
     portContour.interrupt();
     portSFM.interrupt();
     portRpc.interrupt();
     return true;
 }
开发者ID:giuliavezzani,项目名称:ipopt-works,代码行数:11,代码来源:3d-points.cpp


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