Skip to content

Commit 2083222

Browse files
committed
[feature] Allow teams to send a ping to the GC to test network connection
1 parent 60a4690 commit 2083222

File tree

3 files changed

+59
-35
lines changed

3 files changed

+59
-35
lines changed

internal/app/controller/teamConnection.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,19 @@ func (c *GameController) teamConnected(team Team) (connected bool, verified bool
3030
func (c *GameController) ProcessTeamRequests(teamName string, request refproto.TeamToController) error {
3131
c.ConnectionMutex.Lock()
3232
defer c.ConnectionMutex.Unlock()
33+
34+
if _, ok := request.GetMsg().(*refproto.TeamToController_Ping); ok {
35+
return nil
36+
}
37+
3338
log.Print("Received request from team: ", proto.MarshalTextString(&request))
3439

35-
if x, ok := request.GetMsg().(*refproto.TeamToController_AdvantageResponse_); ok {
40+
if msg, ok := request.GetMsg().(*refproto.TeamToController_AdvantageResponse_); ok {
3641
if c.outstandingTeamChoice == nil {
3742
return errors.New("No outstanding choice available. You are probably too late.")
3843
}
3944
responseTime := c.Engine.TimeProvider().Sub(c.outstandingTeamChoice.IssueTime)
40-
if x.AdvantageResponse == refproto.TeamToController_CONTINUE {
45+
if msg.AdvantageResponse == refproto.TeamToController_CONTINUE {
4146
log.Printf("Team %v decided to continue the game within %v", c.outstandingTeamChoice.Team, responseTime)
4247
switch c.outstandingTeamChoice.Event.GameEvent.Type {
4348
case GameEventBotCrashUnique:

pkg/refproto/ssl_game_controller_team.pb.go

Lines changed: 49 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/refproto/ssl_game_controller_team.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ message TeamToController {
2424
AdvantageResponse advantage_response = 3;
2525
// request to substitute a robot at the next possibility
2626
bool substitute_bot = 4;
27+
// send a ping to the GC to test if the connection is still open.
28+
// the value is ignored and a reply is sent back
29+
bool ping = 5;
2730
}
2831

2932
enum AdvantageResponse {

0 commit comments

Comments
 (0)