Skip to content

Commit 8b06f74

Browse files
committed
fix response nullity bug
1 parent be21c72 commit 8b06f74

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

src/grpc-client/grpc_client.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ void GrpcClient::sendServerParam() const
280280

281281
ClientContext context;
282282
protos::Empty empty;
283-
serverParam.set_allocated_register_response(M_register_response);
283+
protos::RegisterResponse* response = new protos::RegisterResponse(*M_register_response);
284+
serverParam.set_allocated_register_response(response);
284285
Status status = M_stub_->SendServerParams(&context, serverParam, &empty);
285286
if (!status.ok())
286287
{
@@ -327,7 +328,8 @@ void GrpcClient::sendPlayerParams() const
327328

328329
ClientContext context;
329330
protos::Empty empty;
330-
playerParam.set_allocated_register_response(M_register_response);
331+
protos::RegisterResponse* response = new protos::RegisterResponse(*M_register_response);
332+
playerParam.set_allocated_register_response(response);
331333
Status status = M_stub_->SendPlayerParams(&context, playerParam, &empty);
332334
if (!status.ok())
333335
{
@@ -385,7 +387,8 @@ void GrpcClient::sendPlayerType() const
385387

386388
ClientContext context;
387389
protos::Empty empty;
388-
playerTypeGrpc.set_allocated_register_response(M_register_response);
390+
protos::RegisterResponse* response = new protos::RegisterResponse(*M_register_response);
391+
playerTypeGrpc.set_allocated_register_response(response);
389392
Status status = M_stub_->SendPlayerType(&context, playerTypeGrpc, &empty);
390393
if (!status.ok())
391394
{
@@ -403,7 +406,8 @@ void GrpcClient::sendInitMessage(bool offline_logging) const
403406
protos::Empty empty;
404407
protos::InitMessage initMessage;
405408
initMessage.set_debug_mode(offline_logging);
406-
initMessage.set_allocated_register_response(M_register_response);
409+
protos::RegisterResponse* response = new protos::RegisterResponse(*M_register_response);
410+
initMessage.set_allocated_register_response(response);
407411
Status status = M_stub_->SendInitMessage(&context, initMessage, &empty);
408412
if (!status.ok())
409413
{

src/grpc-client/grpc_client_coach.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ void GrpcClientCoach::getActions()
5353
{
5454
auto agent = M_agent;
5555
State state = generateState();
56-
state.set_allocated_register_response(M_register_response);
56+
protos::RegisterResponse* response = new protos::RegisterResponse(*M_register_response);
57+
state.set_allocated_register_response(response);
5758
protos::CoachActions actions;
5859
ClientContext context;
5960
Status status = M_stub_->GetCoachActions(&context, state, &actions);

src/grpc-client/grpc_client_player.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ void GrpcClientPlayer::getActions()
109109
{
110110
auto agent = M_agent;
111111
State state = generateState();
112-
state.set_allocated_register_response(M_register_response);
112+
protos::RegisterResponse* response = new protos::RegisterResponse(*M_register_response);
113+
state.set_allocated_register_response(response);
113114
protos::PlayerActions actions;
114115
ClientContext context;
115116
Status status = M_stub_->GetPlayerActions(&context, state, &actions);

src/grpc-client/grpc_client_trainer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ void GrpcClientTrainer::getActions()
5151
{
5252
auto agent = M_agent;
5353
State state = generateState();
54-
state.set_allocated_register_response(M_register_response);
54+
protos::RegisterResponse* response = new protos::RegisterResponse(*M_register_response);
55+
state.set_allocated_register_response(response);
5556
protos::TrainerActions actions;
5657
ClientContext context;
5758
Status status = M_stub_->GetTrainerActions(&context, state, &actions);

0 commit comments

Comments
 (0)