mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 21:56:50 -04:00
Reject connections in a way driver's stations are happier about
Doing it this way allows tethering while FMS is running for robots which aren't in the current match.
This commit is contained in:
@@ -284,19 +284,20 @@ func ListenForDriverStations() {
|
||||
teamId := int(packet[3])<<8 + int(packet[4])
|
||||
|
||||
// Check to see if the team is supposed to be on the field, and notify the DS accordingly.
|
||||
assignedStation := mainArena.getAssignedAllianceStation(teamId)
|
||||
if assignedStation == "" {
|
||||
log.Printf("Rejecting connection from Team %d, who is not in the current match, soon.", teamId)
|
||||
go func() {
|
||||
// Wait a second and then close it so it doesn't chew up bandwidth constantly trying to reconnect.
|
||||
time.Sleep(time.Second)
|
||||
tcpConn.Close()
|
||||
}()
|
||||
continue
|
||||
}
|
||||
var assignmentPacket [5]byte
|
||||
assignmentPacket[0] = 0 // Packet size
|
||||
assignmentPacket[1] = 3 // Packet size
|
||||
assignmentPacket[2] = 25 // Packet type
|
||||
assignedStation := mainArena.getAssignedAllianceStation(teamId)
|
||||
if assignedStation == "" {
|
||||
log.Printf("Rejecting connection from Team %d, who is not in the current match.", teamId)
|
||||
assignmentPacket[3] = 0
|
||||
assignmentPacket[4] = 2
|
||||
tcpConn.Write(assignmentPacket[:])
|
||||
tcpConn.Close()
|
||||
continue
|
||||
}
|
||||
log.Printf("Accepting connection from Team %d in station %s.", teamId, assignedStation)
|
||||
assignmentPacket[3] = allianceStationPositionMap[assignedStation]
|
||||
assignmentPacket[4] = 0
|
||||
|
||||
Reference in New Issue
Block a user