Skip to content

Commit 0f0a41f

Browse files
committed
Re-advertise if the IP or game version changes
1 parent 30e8d3d commit 0f0a41f

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/advertiser/advertiser.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ func StartAdvertiser() {
8080
}
8181
go func() {
8282
sessionId := -1
83+
oldVersion := ""
84+
oldAddress := ""
8385
// Track accumulated transient errors and kill the advertiser if we exceed a threshold
8486
transientErrors := 0
8587
for {
@@ -126,6 +128,14 @@ func StartAdvertiser() {
126128
MaxPlayers: maxplayers,
127129
Type: platform,
128130
}
131+
// Check if the version or address has changed since last advertisement
132+
if (oldVersion != adMessage.Version) || (oldAddress != adMessage.Address) {
133+
// Reset sessionId to force a new advertisement
134+
adMessage.SessionId = -1
135+
}
136+
// Update the saved values
137+
oldVersion = adMessage.Version
138+
oldAddress = adMessage.Address
129139
body, err := json.Marshal(adMessage)
130140
if err != nil {
131141
logger.Advertiser.Warnf("ServerAdvertiser failed to Serialize to JSON from native Go struct type: %v", err)

0 commit comments

Comments
 (0)