Skip to content

Commit

Permalink
Closes #736
Browse files Browse the repository at this point in the history
Note to self: check if this works on Linux/OS X too before documenting it. I might need to change it if it doesn't.
  • Loading branch information
JustArchi committed Jan 30, 2018
1 parent 44d62aa commit 2ee810d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions ArchiSteamFarm/IPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.IO.Compression;
Expand Down Expand Up @@ -172,7 +173,14 @@ internal static class IPC {
}

uint memoryUsage = (uint) GC.GetTotalMemory(true) / 1024;
ASFResponse asfResponse = new ASFResponse(memoryUsage, SharedInfo.Version);

DateTime processStartTime;

using (Process process = Process.GetCurrentProcess()) {
processStartTime = process.StartTime;
}

ASFResponse asfResponse = new ASFResponse(memoryUsage, processStartTime, SharedInfo.Version);

await ResponseJsonObject(request, response, new GenericResponse(true, "OK", asfResponse)).ConfigureAwait(false);
return true;
Expand Down Expand Up @@ -761,15 +769,19 @@ private sealed class ASFResponse {
[JsonProperty]
internal readonly uint MemoryUsage;

[JsonProperty]
internal readonly DateTime ProcessStartTime;

[JsonProperty]
internal readonly Version Version;

internal ASFResponse(uint memoryUsage, Version version) {
if ((memoryUsage == 0) || (version == null)) {
throw new ArgumentNullException(nameof(memoryUsage) + " || " + nameof(version));
internal ASFResponse(uint memoryUsage, DateTime processStartTime, Version version) {
if ((memoryUsage == 0) || (processStartTime == DateTime.MinValue) || (version == null)) {
throw new ArgumentNullException(nameof(memoryUsage) + " || " + nameof(processStartTime) + " || " + nameof(version));
}

MemoryUsage = memoryUsage;
ProcessStartTime = processStartTime;
Version = version;
}
}
Expand Down

0 comments on commit 2ee810d

Please sign in to comment.