Skip to content

Commit

Permalink
Merge pull request #1 from CLSFramework/bye
Browse files Browse the repository at this point in the history
add bye command
  • Loading branch information
naderzare authored Apr 23, 2024
2 parents bfb17c3 + 21117a5 commit 79d9008
Show file tree
Hide file tree
Showing 12 changed files with 254 additions and 7 deletions.
1 change: 1 addition & 0 deletions grpc/protos/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1204,4 +1204,5 @@ service Game {
rpc SendPlayerParams(PlayerParam) returns (Empty) {}
rpc SendPlayerType(PlayerType) returns (Empty) {} //should be PlayerTypes
rpc GetInitMessage(Empty) returns (InitMessageFromServer) {}
rpc SendByeCommand(Empty) returns (Empty) {}
}
7 changes: 7 additions & 0 deletions src/coach/sample_coach.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ SampleCoach::actionImpl()
sayPlayerTypes();
}

void
SampleCoach::handleExit()
{
M_grpc_agent.sendByeCommand();
CoachAgent::handleExit();
}

/*-------------------------------------------------------------------*/
/*!
Expand Down
2 changes: 2 additions & 0 deletions src/coach/sample_coach.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class SampleCoach
//! main decision making
virtual
void actionImpl();
void
handleExit() override;


virtual
Expand Down
15 changes: 15 additions & 0 deletions src/grpc/grpc_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,21 @@ bool GrpcAgent::getInitMessage() const
}
}

void GrpcAgent::sendByeCommand() const
{
ClientContext context;
protos::Empty empty1;
protos::Empty empty2;
Status status = stub_->SendByeCommand(&context, empty1, &empty2);
if (!status.ok())
{
std::cout << "SendByeCommand rpc failed." << std::endl
<< status.error_code() << ": " << status.error_message()
<< std::endl;
}

}

bool GrpcAgent::connectToGrpcServer()
{
channel = grpc::CreateChannel(this->target, grpc::InsecureChannelCredentials());
Expand Down
1 change: 1 addition & 0 deletions src/grpc/grpc_agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class GrpcAgent {
void sendPlayerType() const;
void sendInitMessage(bool offline_logging) const;
bool getInitMessage() const;
void sendByeCommand() const;
bool connectToGrpcServer();

static rcsc::ViewWidth convertViewWidth(protos::ViewWidth view_width);
Expand Down
42 changes: 42 additions & 0 deletions src/grpc/service.grpc.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 79d9008

Please sign in to comment.