Skip to content

Commit adf9565

Browse files
committed
[feature] Add team verification status to UI
1 parent e510bef commit adf9565

File tree

8 files changed

+41
-18
lines changed

8 files changed

+41
-18
lines changed

cmd/ssl-team-client/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/RoboCup-SSL/ssl-game-controller/internal/app/client"
77
"github.com/RoboCup-SSL/ssl-game-controller/pkg/refproto"
88
"github.com/RoboCup-SSL/ssl-go-tools/pkg/sslconn"
9+
"github.com/golang/protobuf/proto"
910
"log"
1011
"net"
1112
)
@@ -117,7 +118,7 @@ func (c *Client) sendRequest(request *refproto.TeamToController) {
117118
request.Signature.Pkcs1V15 = client.Sign(privateKey, request)
118119
}
119120

120-
log.Print("Sending ", request)
121+
log.Print("Sending ", proto.MarshalTextString(request))
121122

122123
if err := sslconn.SendMessage(c.conn, request); err != nil {
123124
log.Fatalf("Failed sending request: %v (%v)", request, err)
@@ -128,7 +129,7 @@ func (c *Client) sendRequest(request *refproto.TeamToController) {
128129
if err := sslconn.ReceiveMessage(c.conn, &reply); err != nil {
129130
log.Fatal("Failed receiving controller reply: ", err)
130131
}
131-
log.Print("Received reply: ", reply)
132+
log.Print("Received reply: ", proto.MarshalTextString(&reply))
132133
if reply.GetControllerReply().StatusCode == nil || *reply.GetControllerReply().StatusCode != refproto.ControllerReply_OK {
133134
log.Print("Message rejected: ", *reply.GetControllerReply().Reason)
134135
}

internal/app/controller/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func (c *GameController) publishUiProtocol() {
142142
// updateOnlineStates checks if teams and autoRefs are online and writes this into the state
143143
func (c *GameController) updateOnlineStates() {
144144
for _, team := range []Team{TeamYellow, TeamBlue} {
145-
c.Engine.State.TeamState[team].Connected = c.teamConnected(team)
145+
c.Engine.State.TeamState[team].Connected, c.Engine.State.TeamState[team].ConnectionVerified = c.teamConnected(team)
146146
}
147147
var autoRefs []string
148148
for _, autoRef := range c.AutoRefServer.Clients {

internal/app/controller/state.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ type TeamInfo struct {
326326
CanPlaceBall bool `json:"canPlaceBall" yaml:"canPlaceBall"`
327327
MaxAllowedBots int `json:"maxAllowedBots" yaml:"maxAllowedBots"`
328328
Connected bool `json:"connected" yaml:"connected"`
329+
ConnectionVerified bool `json:"connectionVerified" yaml:"connectionVerified"`
329330
BotSubstitutionIntend bool `json:"botSubstitutionIntend" yaml:"botSubstitutionIntend"`
330331
}
331332

internal/app/controller/teamConnection.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package controller
22

33
import (
44
"github.com/RoboCup-SSL/ssl-game-controller/pkg/refproto"
5+
"github.com/golang/protobuf/proto"
56
"github.com/pkg/errors"
67
"log"
78
"time"
@@ -14,18 +15,22 @@ type TeamChoice struct {
1415
IssueTime time.Time
1516
}
1617

17-
func (c *GameController) teamConnected(team Team) bool {
18+
func (c *GameController) teamConnected(team Team) (connected bool, verified bool) {
1819
teamName := c.Engine.State.TeamState[team].Name
19-
if _, ok := c.TeamServer.Clients[teamName]; ok {
20-
return true
20+
if client, ok := c.TeamServer.Clients[teamName]; ok {
21+
connected = true
22+
verified = client.VerifiedConnection
23+
return
2124
}
22-
return false
25+
connected = false
26+
verified = false
27+
return
2328
}
2429

2530
func (c *GameController) ProcessTeamRequests(teamName string, request refproto.TeamToController) error {
2631
c.ConnectionMutex.Lock()
2732
defer c.ConnectionMutex.Unlock()
28-
log.Print("Received request from team: ", request)
33+
log.Print("Received request from team: ", proto.MarshalTextString(&request))
2934

3035
if x, ok := request.GetMsg().(*refproto.TeamToController_AdvantageResponse_); ok {
3136
if c.outstandingTeamChoice == nil {

internal/app/rcon/server.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ type Server struct {
2121
}
2222

2323
type Client struct {
24-
Id string
25-
Conn net.Conn
26-
Token string
27-
PubKey *rsa.PublicKey
24+
Id string
25+
Conn net.Conn
26+
Token string
27+
PubKey *rsa.PublicKey
28+
VerifiedConnection bool
2829
}
2930

3031
func NewServer() (s *Server) {
@@ -34,12 +35,12 @@ func NewServer() (s *Server) {
3435
return
3536
}
3637

37-
func (s *Server) Listen(address string) error {
38+
func (s *Server) Listen(address string) {
3839
listener, err := net.Listen("tcp", address)
3940
if err != nil {
40-
return err
41+
log.Print("Failed to listen on ", address)
42+
return
4143
}
42-
defer listener.Close()
4344
log.Print("Listening on ", address)
4445

4546
for {
@@ -49,7 +50,6 @@ func (s *Server) Listen(address string) error {
4950
} else {
5051
go s.ConnectionHandler(conn)
5152
}
52-
5353
}
5454
}
5555

@@ -61,15 +61,21 @@ func (s *Server) CloseConnection(conn net.Conn, id string) {
6161
func (c *Client) Ok() (reply refproto.ControllerReply) {
6262
reply.StatusCode = new(refproto.ControllerReply_StatusCode)
6363
*reply.StatusCode = refproto.ControllerReply_OK
64+
c.addVerification(&reply)
65+
return
66+
}
67+
68+
func (c *Client) addVerification(reply *refproto.ControllerReply) {
6469
reply.Verification = new(refproto.ControllerReply_Verification)
6570
if c.Token != "" {
6671
reply.NextToken = new(string)
6772
*reply.NextToken = c.Token
6873
*reply.Verification = refproto.ControllerReply_VERIFIED
74+
c.VerifiedConnection = true
6975
} else {
7076
*reply.Verification = refproto.ControllerReply_UNVERIFIED
77+
c.VerifiedConnection = false
7178
}
72-
return
7379
}
7480

7581
func (c *Client) Reject(reason string) (reply refproto.ControllerReply) {

src/components/team/TeamOverview.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
class="fa-xs"
99
icon="signal"/>
1010
</span>
11+
<span v-b-tooltip.hover
12+
title="connection verified"
13+
v-if="team.connectionVerified">
14+
<font-awesome-icon
15+
class="fa-xs"
16+
icon="shield-alt"/>
17+
</span>
1118
</h2>
1219
<div class="content">
1320
<div>

src/main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import {
1818
faEdit,
1919
faSignal,
2020
faToggleOff,
21-
faToggleOn
21+
faToggleOn,
22+
faShieldAlt
2223
} from '@fortawesome/free-solid-svg-icons'
2324
import {FontAwesomeIcon} from '@fortawesome/vue-fontawesome'
2425
// Connect to the backend with a single websocket that communicates with JSON format and is attached to the store
@@ -37,6 +38,7 @@ library.add(faToggleOn);
3738
library.add(faToggleOff);
3839
library.add(faSignal);
3940
library.add(faCheckCircle);
41+
library.add(faShieldAlt);
4042
Vue.component('font-awesome-icon', FontAwesomeIcon);
4143

4244

src/store.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export class TeamState {
1818
canPlaceBall = true;
1919
maxAllowedBots = 0;
2020
connected = false;
21+
connectionVerified = false;
2122
}
2223

2324
export class RefBoxState {

0 commit comments

Comments
 (0)