SafeDispatch/MotoRepeaterCore/TallysmanConfirm.cs

62 lines
1.5 KiB
C#
Raw Normal View History

2024-02-22 16:43:59 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.CompilerServices;
namespace MotoRepeater
{
static class TallysmanConfirm
{
private static Dictionary<int, String> toBeConfirmed = new Dictionary<int, String>();
private static int index;
static TallysmanConfirm()
{
index = 65534;
}
public static int addToConfirmationQueue(String seq_idFromSD)
{
lock (toBeConfirmed)
{
if (!toBeConfirmed.ContainsKey(index))
{
toBeConfirmed.Add(index, seq_idFromSD);
}
else
{
toBeConfirmed[index] = seq_idFromSD;
}
if (index < 65535)
{
index++;
return index - 1;
}
else
{
index = 1;
return 65535;
}
}
}
public static String getFromConfirmationQueue(int index)
{
String toReturn;
lock (toBeConfirmed)
{
if (toBeConfirmed.ContainsKey(index))
{
toReturn = toBeConfirmed[index];
}
else
{
toReturn = "";
}
return toReturn;
}
}
}
}