From 2083222777bf7dada83405dd1ddd6dec0ed542d6 Mon Sep 17 00:00:00 2001 From: Nicolai Ommer Date: Fri, 3 May 2019 11:38:02 +0200 Subject: [PATCH] [feature] Allow teams to send a ping to the GC to test network connection --- internal/app/controller/teamConnection.go | 9 ++- pkg/refproto/ssl_game_controller_team.pb.go | 82 ++++++++++++--------- pkg/refproto/ssl_game_controller_team.proto | 3 + 3 files changed, 59 insertions(+), 35 deletions(-) diff --git a/internal/app/controller/teamConnection.go b/internal/app/controller/teamConnection.go index 0fcf5575..df2ab629 100644 --- a/internal/app/controller/teamConnection.go +++ b/internal/app/controller/teamConnection.go @@ -30,14 +30,19 @@ func (c *GameController) teamConnected(team Team) (connected bool, verified bool func (c *GameController) ProcessTeamRequests(teamName string, request refproto.TeamToController) error { c.ConnectionMutex.Lock() defer c.ConnectionMutex.Unlock() + + if _, ok := request.GetMsg().(*refproto.TeamToController_Ping); ok { + return nil + } + log.Print("Received request from team: ", proto.MarshalTextString(&request)) - if x, ok := request.GetMsg().(*refproto.TeamToController_AdvantageResponse_); ok { + if msg, ok := request.GetMsg().(*refproto.TeamToController_AdvantageResponse_); ok { if c.outstandingTeamChoice == nil { return errors.New("No outstanding choice available. You are probably too late.") } responseTime := c.Engine.TimeProvider().Sub(c.outstandingTeamChoice.IssueTime) - if x.AdvantageResponse == refproto.TeamToController_CONTINUE { + if msg.AdvantageResponse == refproto.TeamToController_CONTINUE { log.Printf("Team %v decided to continue the game within %v", c.outstandingTeamChoice.Team, responseTime) switch c.outstandingTeamChoice.Event.GameEvent.Type { case GameEventBotCrashUnique: diff --git a/pkg/refproto/ssl_game_controller_team.pb.go b/pkg/refproto/ssl_game_controller_team.pb.go index ab2011bd..a49547cb 100644 --- a/pkg/refproto/ssl_game_controller_team.pb.go +++ b/pkg/refproto/ssl_game_controller_team.pb.go @@ -170,6 +170,7 @@ type TeamToController struct { // *TeamToController_DesiredKeeper // *TeamToController_AdvantageResponse_ // *TeamToController_SubstituteBot + // *TeamToController_Ping Msg isTeamToController_Msg `protobuf_oneof:"msg"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -224,12 +225,18 @@ type TeamToController_SubstituteBot struct { SubstituteBot bool `protobuf:"varint,4,opt,name=substitute_bot,json=substituteBot,oneof"` } +type TeamToController_Ping struct { + Ping bool `protobuf:"varint,5,opt,name=ping,oneof"` +} + func (*TeamToController_DesiredKeeper) isTeamToController_Msg() {} func (*TeamToController_AdvantageResponse_) isTeamToController_Msg() {} func (*TeamToController_SubstituteBot) isTeamToController_Msg() {} +func (*TeamToController_Ping) isTeamToController_Msg() {} + func (m *TeamToController) GetMsg() isTeamToController_Msg { if m != nil { return m.Msg @@ -258,12 +265,20 @@ func (m *TeamToController) GetSubstituteBot() bool { return false } +func (m *TeamToController) GetPing() bool { + if x, ok := m.GetMsg().(*TeamToController_Ping); ok { + return x.Ping + } + return false +} + // XXX_OneofWrappers is for the internal use of the proto package. func (*TeamToController) XXX_OneofWrappers() []interface{} { return []interface{}{ (*TeamToController_DesiredKeeper)(nil), (*TeamToController_AdvantageResponse_)(nil), (*TeamToController_SubstituteBot)(nil), + (*TeamToController_Ping)(nil), } } @@ -419,37 +434,38 @@ func init() { func init() { proto.RegisterFile("ssl_game_controller_team.proto", fileDescriptor_96c0c3d07dcb3676) } var fileDescriptor_96c0c3d07dcb3676 = []byte{ - // 504 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xd1, 0x6e, 0x12, 0x41, - 0x14, 0x86, 0x77, 0x81, 0x46, 0x38, 0x6d, 0xe9, 0x74, 0x12, 0x23, 0xad, 0x89, 0x21, 0x78, 0x21, - 0xde, 0xac, 0xca, 0x9d, 0x17, 0x35, 0x91, 0x05, 0x0b, 0x69, 0xb3, 0x90, 0x61, 0x89, 0xf1, 0x6a, - 0x32, 0x2c, 0x47, 0xd8, 0xb8, 0xbb, 0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xfa, 0xd2, 0xf8, 0x56, 0x31, 0x2f, 0x04, 0xac, 0xb9, 0xd8, 0x7b, 0xd3, 0x2b, 0xb0, 0x84, - 0x6f, 0x72, 0xbd, 0xc6, 0x65, 0x71, 0x8d, 0x6a, 0x61, 0xf1, 0x6c, 0xdf, 0x62, 0x5a, 0xd4, 0xfb, - 0xd2, 0xb0, 0x93, 0xc5, 0xa3, 0x57, 0xe7, 0x0d, 0xd4, 0x6c, 0x22, 0x7a, 0x0c, 0x4f, 0xe6, 0xc1, - 0x4d, 0x30, 0xf9, 0x1c, 0x10, 0xc7, 0xde, 0xc8, 0x9f, 0xdc, 0xde, 0x8e, 0x67, 0xe3, 0x49, 0x40, - 0x5c, 0x5b, 0x9b, 0xce, 0x67, 0xa3, 0x71, 0x70, 0x4d, 0x2a, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, - 0x86, 0xe4, 0xc1, 0x7c, 0x74, 0x03, 0x00, 0x00, + // 517 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xcf, 0x6e, 0xd3, 0x4e, + 0x10, 0xc7, 0xed, 0x34, 0xd1, 0x2f, 0x99, 0xb6, 0xe9, 0x76, 0xf5, 0x43, 0xa4, 0x45, 0x42, 0x51, + 0x38, 0x10, 0x2e, 0x06, 0x72, 0xe3, 0x50, 0x24, 0xe2, 0x84, 0x26, 0x6a, 0xe5, 0x44, 0x1b, 0x47, + 0x88, 0xd3, 0x6a, 0xe3, 0x0c, 0x8e, 0x85, 0xed, 0x35, 0xde, 0x75, 0x25, 0x9e, 0x84, 0xe7, 0xe1, + 0x91, 0x78, 0x03, 0xb4, 0x6e, 0x52, 0x37, 0x01, 0x71, 0x9c, 0xcf, 0xf7, 0x3b, 0x7f, 0x76, 0x66, + 0xe1, 0xb9, 0x52, 0x31, 0x0f, 0x45, 0x82, 0x3c, 0x90, 0xa9, 0xce, 0x65, 0x1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, 0xc4, 0xd3, 0xfd, 0x12, 0xf3, 0x52, 0x1f, 0x4a, 0xcd, 0x4e, + 0x56, 0x8f, 0xa2, 0xde, 0x6b, 0xa8, 0x9b, 0x89, 0xe8, 0x31, 0xfc, 0xb7, 0xf4, 0x6e, 0xbc, 0xd9, + 0x27, 0x8f, 0x58, 0xe6, 0x46, 0xee, 0xec, 0xf6, 0x76, 0xba, 0x98, 0xce, 0x3c, 0x62, 0x1b, 0x6d, + 0xbe, 0x5c, 0x4c, 0xa6, 0xde, 0x35, 0xa9, 0xfd, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x07, 0xd5, 0x33, + 0xd3, 0x8a, 0x03, 0x00, 0x00, } diff --git a/pkg/refproto/ssl_game_controller_team.proto b/pkg/refproto/ssl_game_controller_team.proto index a2694e4f..2d098182 100644 --- a/pkg/refproto/ssl_game_controller_team.proto +++ b/pkg/refproto/ssl_game_controller_team.proto @@ -24,6 +24,9 @@ message TeamToController { AdvantageResponse advantage_response = 3; // request to substitute a robot at the next possibility bool substitute_bot = 4; + // send a ping to the GC to test if the connection is still open. + // the value is ignored and a reply is sent back + bool ping = 5; } enum AdvantageResponse {