Merge pull request #111 from RaidMax/enhancement/issue-108-address-t6-specific-behaviors

re-kick working as expected now
This commit is contained in:
RaidMax 2020-02-07 11:16:27 -06:00 committed by GitHub
commit ec053eb854
3 changed files with 36 additions and 9 deletions

View File

@ -439,7 +439,7 @@ namespace IW4MAdmin
if (isPotentialFalseQuit)
{
Logger.WriteInfo($"Receive predisconnect event for {E}, but it occured at game time {E.GameTime.Value}, which is the same last map change, so we're ignoring");
Logger.WriteInfo($"Receive predisconnect event for {E.Origin}, but it occured at game time {E.GameTime.Value}, which is the same last map change, so we're ignoring");
return false;
}
@ -453,7 +453,7 @@ namespace IW4MAdmin
return false;
}
else if (client.State == ClientState.Connected)
else if (client.State != ClientState.Unknown)
{
#if DEBUG == true
Logger.WriteDebug($"Begin PreDisconnect for {client}");
@ -623,7 +623,7 @@ namespace IW4MAdmin
else if (client.IPAddress != null && client.State == ClientState.Disconnecting)
{
Logger.WriteWarning($"{client} state is Disconnecting (probably kicked), but they are still connected. trying to kick again...");
Logger.WriteWarning($"{client} state is Unknown (probably kicked), but they are still connected. trying to kick again...");
await client.CanConnect(client.IPAddress);
}
}

View File

@ -367,17 +367,31 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
{
pl.CurrentServer.Logger.WriteInfo($"Removing {pl} from stats");
if (pl.CurrentServer == null)
{
pl.CurrentServer.Logger.WriteWarning($"Disconnecting client {pl} is not on a server, state is {pl.State}");
return;
}
long serverId = GetIdForServer(pl.CurrentServer);
var serverStats = _servers[serverId].ServerStatistics;
// get individual client's stats
var clientStats = pl.GetAdditionalProperty<EFClientStatistics>(CLIENT_STATS_KEY);
// sync their stats before they leave
clientStats = UpdateStats(clientStats);
await SaveClientStats(clientStats);
if (clientStats != null)
{
clientStats = UpdateStats(clientStats);
await SaveClientStats(clientStats);
// increment the total play time
serverStats.TotalPlayTime += pl.ConnectionLength;
// increment the total play time
serverStats.TotalPlayTime += pl.ConnectionLength;
}
else
{
pl.CurrentServer.Logger.WriteWarning($"Disconnecting client {pl} has not been added to stats, state is {pl.State}");
}
}
private static async Task SaveClientStats(EFClientStatistics clientStats)

View File

@ -15,20 +15,27 @@ namespace SharedLibraryCore.Database.Models
{
public enum ClientState
{
/// <summary>
/// default client state
/// </summary>
Unknown,
/// <summary>
/// represents when the client has been detected as joining
/// by the log file, but has not be authenticated by RCon
/// </summary>
Connecting,
/// <summary>
/// represents when the client has been authenticated by RCon
/// and validated by the database
/// </summary>
Connected,
/// <summary>
/// represents when the client is leaving (either through RCon or log file)
/// </summary>
Disconnecting,
Disconnecting
}
public enum Permission
@ -358,6 +365,7 @@ namespace SharedLibraryCore.Database.Models
e.FailReason = GameEvent.EventFailReason.Permission;
}
State = ClientState.Disconnecting;
sender.CurrentServer.Manager.GetEventHandler().AddEvent(e);
return e;
}
@ -391,6 +399,7 @@ namespace SharedLibraryCore.Database.Models
e.FailReason = GameEvent.EventFailReason.Invalid;
}
State = ClientState.Disconnecting;
sender.CurrentServer.Manager.GetEventHandler().AddEvent(e);
return e;
}
@ -506,7 +515,6 @@ namespace SharedLibraryCore.Database.Models
public async Task OnDisconnect()
{
State = ClientState.Disconnecting;
TotalConnectionTime += ConnectionLength;
LastConnection = DateTime.UtcNow;
@ -520,6 +528,11 @@ namespace SharedLibraryCore.Database.Models
CurrentServer.Logger.WriteWarning($"Could not update disconnected player {this}");
CurrentServer.Logger.WriteDebug(e.GetExceptionInfo());
}
finally
{
State = ClientState.Unknown;
}
}
public async Task OnJoin(int? ipAddress)