|
|
@@ -1,21 +1,18 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Concurrent; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Threading; |
|
|
|
using System.Collections.Concurrent; |
|
|
|
using JT808.Protocol.Interfaces; |
|
|
|
|
|
|
|
namespace JT808.Protocol.Internal |
|
|
|
{ |
|
|
|
internal class DefaultMsgSNDistributedImpl : IJT808MsgSNDistributed |
|
|
|
{ |
|
|
|
ConcurrentDictionary<string, ushort> counterDict; |
|
|
|
readonly ConcurrentDictionary<string, ushort> counterDict; |
|
|
|
public DefaultMsgSNDistributedImpl() |
|
|
|
{ |
|
|
|
counterDict = new ConcurrentDictionary<string, ushort>(StringComparer.OrdinalIgnoreCase); |
|
|
|
} |
|
|
|
public ushort Increment(string terminalPhoneNo) |
|
|
|
{ |
|
|
|
if (counterDict.TryGetValue(terminalPhoneNo, out ushort value)) |
|
|
|
if (counterDict.TryGetValue(terminalPhoneNo, out ushort value)) |
|
|
|
{ |
|
|
|
ushort newValue = ++value; |
|
|
|
counterDict.TryUpdate(terminalPhoneNo, newValue, value); |
|
|
@@ -23,8 +20,8 @@ namespace JT808.Protocol.Internal |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
counterDict.TryAdd(terminalPhoneNo, 1); |
|
|
|
return 1; |
|
|
|
counterDict.TryAdd(terminalPhoneNo, 0); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|