sharp-chat/SharpChat/SharpId.cs

15 lines
381 B
C#
Raw Permalink Normal View History

2023-02-08 03:32:12 +00:00
using System;
using System.Threading;
namespace SharpChat {
public static class SharpId {
private const long EPOCH = 1588377600000;
private static int Counter = 0;
public static long Next()
=> ((DateTimeOffset.Now.ToUnixTimeMilliseconds() - EPOCH) << 8)
| (ushort)(Interlocked.Increment(ref Counter) & 0xFFFF);
}
}