mirror of
https://github.com/weiaiweiai/NezhaAgentHTTPBridge.git
synced 2026-05-14 05:59:07 +08:00
Add files via upload
This commit is contained in:
30
WebApplication4/Services/WebSocketMessageStore.cs
Normal file
30
WebApplication4/Services/WebSocketMessageStore.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace WebApplication4.Services
|
||||
{
|
||||
public class WebSocketMessageStore
|
||||
{
|
||||
private string? _lastMessage;
|
||||
private DateTime? _receivedAtUtc;
|
||||
private readonly object _lock = new();
|
||||
|
||||
public void Set(string message)
|
||||
{
|
||||
if (message == null) return;
|
||||
lock (_lock)
|
||||
{
|
||||
_lastMessage = message;
|
||||
_receivedAtUtc = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
|
||||
public (string? Message, DateTime? ReceivedAtUtc) Get()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
return (_lastMessage, _receivedAtUtc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user