v2rayN/v2rayN/ServiceLib/Manager/NoticeManager.cs
2dust 058c6e4a85
Some checks are pending
release Linux / build (Release) (push) Waiting to run
release macOS / build (Release) (push) Waiting to run
release Windows desktop (Avalonia UI) / build (Release) (push) Waiting to run
release Windows / build (Release) (push) Waiting to run
Use Rx event subscription instead of MessageBus to send information
2025-08-29 15:46:09 +08:00

41 lines
926 B
C#

namespace ServiceLib.Manager;
public class NoticeManager
{
private static readonly Lazy<NoticeManager> _instance = new(() => new());
public static NoticeManager Instance => _instance.Value;
public void Enqueue(string? content)
{
if (content.IsNullOrEmpty())
{
return;
}
AppEvents.SendSnackMsgRequested.OnNext(content);
}
public void SendMessage(string? content)
{
if (content.IsNullOrEmpty())
{
return;
}
AppEvents.SendMsgViewRequested.OnNext(content);
}
public void SendMessageEx(string? content)
{
if (content.IsNullOrEmpty())
{
return;
}
content = $"{DateTime.Now:yyyy/MM/dd HH:mm:ss} {content}";
SendMessage(content);
}
public void SendMessageAndEnqueue(string? msg)
{
Enqueue(msg);
SendMessage(msg);
}
}