Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion TallyDB/Core/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using static System.Environment;
using static System.Environment;

namespace TallyDB.Core
{
Expand All @@ -14,5 +14,6 @@ public static class Constants
#else
public static string TallyRoot = Path.Join(GetFolderPath(SpecialFolder.ApplicationData), "TallyDB/");
#endif
public static TimeSpan ConnectionTimeout = TimeSpan.FromMinutes(1);
}
}
11 changes: 11 additions & 0 deletions TallyDB/Server/ClientHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Text;
using TallyDB.Config;
using TallyDB.Config.Auth;
using TallyDB.Core;
using TallyDB.Server.QueryProcessor;
using TallyDB.Server.Types;

Expand All @@ -20,6 +21,7 @@ public void Handle(Socket client)
User? authUser = null;
var authStorage = new AuthStorage(new FileOperator());
var requestProcessor = new RequestProcessor();
var connectionTimeout = DateTime.Now.Add(Constants.ConnectionTimeout);

while (true)
{
Expand All @@ -42,6 +44,15 @@ public void Handle(Socket client)
value += (Convert.ToChar(data[i]));
}

#region Connection Keep Alive
// reset connection timeout
if (connectionTimeout < DateTime.Now)
{
break;
}
connectionTimeout = DateTime.Now.Add(Constants.ConnectionTimeout);
#endregion

var request = JsonConvert.DeserializeObject<QueryRequest>(value);

if (request != null)
Expand Down