-
-
Notifications
You must be signed in to change notification settings - Fork 21
Saving & Restoring
Gopher Game Server can save it's state when shutting down, and then restore the previous state when booted back up again. A "state" saves all Rooms
and their info/variables/invite lists. If a Room
was created by a client and RoomDeleteOnLeave
in gopher.ServerSettings
is enabled, the Room
will not be saved. This is because all User
s are kicked before saving all Room
s, and RoomDeleteOnLeave
deletes a Room
when the owner leaves (they got kicked, and therefore left the Room
, causing it to delete itself).
Each time the server saves it's state, it makes a new .gsf
file in the specified save folder on your system. When booting up, Gopher will search through the save file for the most recently saved state, and boot with that one.
Setting up the save and restore feature requires two entries in gopher.ServerSettings
to be set: EnableRecovery
, and RecoveryLocation
. Ex:
package main
import (
"github.com/hewiefreeman/GopherGameServer"
)
func main() {
settings := gopher.ServerSettings{
ServerName: "!s!",
MaxConnections: 10000,
HostName: "http://example.com",
HostAlias: "http://www.example.com",
IP: "192.168.1.1",
Port: 8080,
OriginOnly: true,
// Enable save & recovery and set save folder
EnableRecovery: true,
RecoveryLocation: "C:/your/save/folder",
}
gopher.Start(&settings)
}
The RecoveryLocation
must be a valid folder location on your system, and have proper permissions to read/write. If not, your recovery files might not get saved.
If you notice there is lacking information, missing features, or bad explanations, please open an issue. All requests are acceptable and will be taken into consideration.