void FitnessService::start_listen() { bool poweroff = false; while (!poweroff) { Connection client = connection_listener.accept(); int methodID = client.readInt4(); std::cout<<"method "<<methodID<<" called!"<<std::endl; switch (methodID) { case RPC_START: rpc_start(client); break; case RPC_FITNESS: rpc_fitness(client); break; case RPC_POSITION: rpc_position(client); break; default: std::cerr<<"id "<<methodID<<" not implemented"<<std::endl; } } }
static int start_rpc(int fd) { LOG_ENTRY; struct rpc *rpc = NULL; rpc = rpc_alloc(); if (!rpc) { RPC_ERROR("out of memory"); goto fail; } if (rpc_init(fd, gps_rpc_handler, rpc)) { RPC_ERROR("failed to init RPC"); goto fail; } if (rpc_start(rpc)) { RPC_ERROR("failed to start RPC"); goto fail; } gps_rpc = rpc; LOG_EXIT; return 0; fail: if (rpc) { rpc_free(rpc); } LOG_EXIT; return -1; }