-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathKtaneWebSession.cs
More file actions
37 lines (31 loc) · 1.19 KB
/
KtaneWebSession.cs
File metadata and controls
37 lines (31 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using RT.Serialization;
using RT.Servers;
namespace KtaneWeb
{
sealed class KtaneWebSession(KtaneWebConfig config) : Session, ISessionEquatable<KtaneWebSession>
{
public string Username;
protected override void DeleteSession()
{
lock (_config)
_config.Sessions.Remove(SessionID);
}
protected override bool ReadSession()
{
lock (_config)
return _config.Sessions.TryGetValue(SessionID, out Username);
}
protected override void SaveSession()
{
lock (_config)
_config.Sessions[SessionID] = Username;
}
KtaneWebSession ISessionEquatable<KtaneWebSession>.DeepClone() => new(_config) { Username = Username };
bool IEquatable<KtaneWebSession>.Equals(KtaneWebSession other) => other != null && string.Equals(Username, other.Username);
public override bool Equals(object obj) => obj is KtaneWebSession other && string.Equals(Username, other.Username);
public override int GetHashCode() => Username.GetHashCode();
[ClassifyIgnore]
private readonly KtaneWebConfig _config = config;
}
}