forked from PGR/ascnet
1
0
Fork 0

Long overdue save command

This commit is contained in:
Kyle Belanger 2024-04-11 05:11:34 -04:00
parent e866af9ee9
commit e400325184
2 changed files with 26 additions and 5 deletions

View File

@ -0,0 +1,15 @@
namespace AscNet.GameServer.Commands
{
[CommandName("save")]
internal class SaveCommand : Command
{
public SaveCommand(Session session, string[] args, bool validate = true) : base(session, args, validate) { }
public override string Help => "Command to save the current session state to the database";
public override void Execute()
{
session.Save();
}
}
}

View File

@ -227,15 +227,21 @@ namespace AscNet.GameServer
return; return;
// DB save on disconnect // DB save on disconnect
log.Info($"Saving session state..."); Save();
player?.Save();
character?.Save();
stage?.Save();
inventory?.Save();
log.Warn($"{id} disconnected"); log.Warn($"{id} disconnected");
client.Close(); client.Close();
Server.Instance.Sessions.Remove(id); Server.Instance.Sessions.Remove(id);
} }
public void Save()
{
player?.Save();
character?.Save();
stage?.Save();
inventory?.Save();
log.Info($"Saving session state...");
}
} }
} }