Skip to content

Commit f4e58c7

Browse files
committed
added check for running Factorio server before sending command
1 parent 3bf1f0c commit f4e58c7

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/wsroutes.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,19 @@ func logSubscribe(client *Client, data interface{}) {
2222
}
2323

2424
func commandSend(client *Client, data interface{}) {
25-
go func() {
26-
log.Printf("Received command: %v", data)
25+
if FactorioServ.Running {
26+
go func() {
27+
log.Printf("Received command: %v", data)
2728

28-
req_id, err := FactorioServ.Rcon.Write(data.(string))
29-
if err != nil {
30-
log.Printf("Error sending rcon command: %s", err)
31-
return
32-
}
29+
req_id, err := FactorioServ.Rcon.Write(data.(string))
30+
if err != nil {
31+
log.Printf("Error sending rcon command: %s", err)
32+
return
33+
}
3334

34-
log.Printf("Command send to Factorio: %s, with rcon request id: %v", data, req_id)
35+
log.Printf("Command send to Factorio: %s, with rcon request id: %v", data, req_id)
3536

36-
client.send <- Message{"receive command", data}
37-
}()
37+
client.send <- Message{"receive command", data}
38+
}()
39+
}
3840
}

0 commit comments

Comments
 (0)