1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const number_allocator_1 = require("number-allocator");
|
4 | class UniqueMessageIdProvider {
|
5 | constructor() {
|
6 | this.numberAllocator = new number_allocator_1.NumberAllocator(1, 65535);
|
7 | }
|
8 | allocate() {
|
9 | this.lastId = this.numberAllocator.alloc();
|
10 | return this.lastId;
|
11 | }
|
12 | getLastAllocated() {
|
13 | return this.lastId;
|
14 | }
|
15 | register(messageId) {
|
16 | return this.numberAllocator.use(messageId);
|
17 | }
|
18 | deallocate(messageId) {
|
19 | this.numberAllocator.free(messageId);
|
20 | }
|
21 | clear() {
|
22 | this.numberAllocator.clear();
|
23 | }
|
24 | }
|
25 | exports.default = UniqueMessageIdProvider;
|
26 |
|
\ | No newline at end of file |