Code-style consistency improvement:
Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files. make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type. This commit contains no other changes aside from adding and applying clang-format-all.sh
This commit is contained in:
@@ -24,14 +24,12 @@ static unsigned int b3DeserializeInt2(const unsigned char* input)
|
||||
|
||||
bool gVerboseNetworkMessagesClient3 = false;
|
||||
|
||||
|
||||
struct GRPCNetworkedInternalData
|
||||
struct GRPCNetworkedInternalData
|
||||
{
|
||||
std::shared_ptr<grpc::Channel> m_grpcChannel;
|
||||
std::unique_ptr< PyBulletAPI::Stub> m_stub;
|
||||
|
||||
std::unique_ptr<PyBulletAPI::Stub> m_stub;
|
||||
|
||||
bool m_isConnected;
|
||||
bool m_isConnected;
|
||||
|
||||
SharedMemoryCommand m_clientCmd;
|
||||
bool m_hasCommand;
|
||||
@@ -46,12 +44,10 @@ struct GRPCNetworkedInternalData
|
||||
double m_timeOutInSeconds;
|
||||
|
||||
GRPCNetworkedInternalData()
|
||||
:
|
||||
m_isConnected(false),
|
||||
m_hasCommand(false),
|
||||
m_timeOutInSeconds(60)
|
||||
: m_isConnected(false),
|
||||
m_hasCommand(false),
|
||||
m_timeOutInSeconds(60)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void disconnect()
|
||||
@@ -72,16 +68,14 @@ struct GRPCNetworkedInternalData
|
||||
{
|
||||
hostport += ':' + std::to_string(m_port);
|
||||
}
|
||||
m_grpcChannel = grpc::CreateChannel(
|
||||
m_grpcChannel = grpc::CreateChannel(
|
||||
hostport, grpc::InsecureChannelCredentials());
|
||||
|
||||
m_stub = PyBulletAPI::NewStub(m_grpcChannel);
|
||||
|
||||
|
||||
|
||||
// Set timeout for API
|
||||
std::chrono::system_clock::time_point deadline =
|
||||
std::chrono::system_clock::now()+std::chrono::seconds((long long)m_timeOutInSeconds);
|
||||
std::chrono::system_clock::now() + std::chrono::seconds((long long)m_timeOutInSeconds);
|
||||
grpc::ClientContext context;
|
||||
context.set_deadline(deadline);
|
||||
::pybullet_grpc::PyBulletCommand request;
|
||||
@@ -106,21 +100,16 @@ struct GRPCNetworkedInternalData
|
||||
printf("Error: cannot connect to GRPC server\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
return m_isConnected;
|
||||
}
|
||||
|
||||
bool checkData()
|
||||
{
|
||||
|
||||
bool hasStatus = false;
|
||||
return hasStatus;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
GRPCNetworkedPhysicsProcessor::GRPCNetworkedPhysicsProcessor(const char* hostName, int port)
|
||||
{
|
||||
m_data = new GRPCNetworkedInternalData;
|
||||
@@ -129,7 +118,6 @@ GRPCNetworkedPhysicsProcessor::GRPCNetworkedPhysicsProcessor(const char* hostNam
|
||||
m_data->m_hostName = hostName;
|
||||
}
|
||||
m_data->m_port = port;
|
||||
|
||||
}
|
||||
|
||||
GRPCNetworkedPhysicsProcessor::~GRPCNetworkedPhysicsProcessor()
|
||||
@@ -140,7 +128,7 @@ GRPCNetworkedPhysicsProcessor::~GRPCNetworkedPhysicsProcessor()
|
||||
|
||||
bool GRPCNetworkedPhysicsProcessor::processCommand(const struct SharedMemoryCommand& clientCmd, struct SharedMemoryStatus& serverStatusOut, char* bufferServerToClient, int bufferSizeInBytes)
|
||||
{
|
||||
if(gVerboseNetworkMessagesClient3)
|
||||
if (gVerboseNetworkMessagesClient3)
|
||||
{
|
||||
printf("GRPCNetworkedPhysicsProcessor::processCommand\n");
|
||||
}
|
||||
@@ -157,18 +145,16 @@ bool GRPCNetworkedPhysicsProcessor::processCommand(const struct SharedMemoryComm
|
||||
::pybullet_grpc::PyBulletStatus status;
|
||||
// The actual RPC.
|
||||
grpc::Status grpcStatus = m_data->m_stub->SubmitCommand(&context, grpcCommand, &status);
|
||||
|
||||
|
||||
//convert grpc status to Bullet status
|
||||
bool convertedOk = convertGRPCToStatus(status, serverStatusOut, bufferServerToClient, bufferSizeInBytes);
|
||||
if (!convertedOk)
|
||||
{
|
||||
disconnect();
|
||||
|
||||
}
|
||||
return convertedOk;
|
||||
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -197,20 +183,16 @@ bool GRPCNetworkedPhysicsProcessor::receiveStatus(struct SharedMemoryStatus& ser
|
||||
{
|
||||
printf("Error: steam buffer overflow\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return hasStatus;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GRPCNetworkedPhysicsProcessor::renderScene(int renderFlags)
|
||||
{
|
||||
}
|
||||
|
||||
void GRPCNetworkedPhysicsProcessor::physicsDebugDraw(int debugDrawFlags)
|
||||
void GRPCNetworkedPhysicsProcessor::physicsDebugDraw(int debugDrawFlags)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -223,7 +205,6 @@ bool GRPCNetworkedPhysicsProcessor::isConnected() const
|
||||
return m_data->m_isConnected;
|
||||
}
|
||||
|
||||
|
||||
bool GRPCNetworkedPhysicsProcessor::connect()
|
||||
{
|
||||
bool isConnected = m_data->connectGRPC();
|
||||
@@ -233,14 +214,11 @@ bool GRPCNetworkedPhysicsProcessor::connect()
|
||||
void GRPCNetworkedPhysicsProcessor::disconnect()
|
||||
{
|
||||
m_data->disconnect();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GRPCNetworkedPhysicsProcessor::setTimeOut(double timeOutInSeconds)
|
||||
{
|
||||
m_data->m_timeOutInSeconds = timeOutInSeconds;
|
||||
}
|
||||
|
||||
#endif //BT_ENABLE_GRPC
|
||||
|
||||
#endif //BT_ENABLE_GRPC
|
||||
|
||||
Reference in New Issue
Block a user