jp.ms.common.modules 1.0.40 → 1.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dto/app-table/bids-panel-item.dto.d.ts +6 -0
- package/dist/dto/app-table/bids-panel-item.dto.js +52 -0
- package/dist/dto/app-table/bids-panel-item.dto.js.map +1 -0
- package/dist/dto/app-table/bids-panel.dto.d.ts +7 -0
- package/dist/dto/app-table/bids-panel.dto.js +50 -0
- package/dist/dto/app-table/bids-panel.dto.js.map +1 -0
- package/dist/dto/app-table/index.d.ts +2 -0
- package/dist/dto/app-table/index.js +5 -1
- package/dist/dto/app-table/index.js.map +1 -1
- package/dist/dto/games/poker/poker-table.dto.d.ts +2 -1
- package/dist/dto/games/poker/poker-table.dto.js +6 -0
- package/dist/dto/games/poker/poker-table.dto.js.map +1 -1
- package/dist/modules/anti-freeze-system/anti-freeze-system.module.d.ts +3 -1
- package/dist/modules/anti-freeze-system/anti-freeze-system.module.js +8 -4
- package/dist/modules/anti-freeze-system/anti-freeze-system.module.js.map +1 -1
- package/dist/modules/anti-freeze-system/anti-freeze-system.service.d.ts +6 -2
- package/dist/modules/anti-freeze-system/anti-freeze-system.service.js +37 -10
- package/dist/modules/anti-freeze-system/anti-freeze-system.service.js.map +1 -1
- package/dist/modules/base-achievements/base-achievements.module.js +4 -4
- package/dist/modules/base-achievements/base-achievements.module.js.map +1 -1
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.constants.d.ts +1 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.constants.js +5 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.constants.js.map +1 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.interfaces.d.ts +13 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.interfaces.js +3 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.interfaces.js.map +1 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.module.d.ts +15 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.module.js +77 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.module.js.map +1 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.service.d.ts +19 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.service.js +83 -0
- package/dist/modules/confirmation-message-manager/confirmation-message-manager.service.js.map +1 -0
- package/dist/modules/event-bus/events-bus.module.js +3 -0
- package/dist/modules/event-bus/events-bus.module.js.map +1 -1
- package/dist/modules/event-bus/events-bus.player-ws-message.subscribe.service.d.ts +10 -0
- package/dist/modules/event-bus/events-bus.player-ws-message.subscribe.service.js +26 -0
- package/dist/modules/event-bus/events-bus.player-ws-message.subscribe.service.js.map +1 -0
- package/dist/modules/event-bus/index.d.ts +1 -0
- package/dist/modules/event-bus/index.js +3 -1
- package/dist/modules/event-bus/index.js.map +1 -1
- package/dist/modules/events/events.gateway.d.ts +6 -1
- package/dist/modules/events/events.gateway.js +15 -3
- package/dist/modules/events/events.gateway.js.map +1 -1
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +3 -1
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/main/main.module.js +1 -1
- package/dist/modules/main/main.module.js.map +1 -1
- package/dist/modules/main/main.service.js +1 -1
- package/dist/modules/many-tables-tournament/many-tables-tournament.module.js +1 -1
- package/dist/modules/many-tables-tournament/many-tables-tournament.module.js.map +1 -1
- package/dist/modules/menu/menu-screen.view.js +1 -1
- package/dist/modules/menu/menu-screen.view.js.map +1 -1
- package/dist/modules/menu/menu.service.js +1 -1
- package/dist/modules/menu/menu.service.js.map +1 -1
- package/dist/modules/one-table-tournament/one-table-tournament.module.js +1 -1
- package/dist/modules/one-table-tournament/one-table-tournament.module.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/dto/app-table/bids-panel-item.dto.ts +33 -0
- package/src/dto/app-table/bids-panel.dto.ts +32 -0
- package/src/dto/app-table/index.ts +2 -0
- package/src/dto/games/poker/poker-table.dto.ts +5 -0
- package/src/modules/anti-freeze-system/anti-freeze-system.module.ts +6 -2
- package/src/modules/anti-freeze-system/anti-freeze-system.service.ts +38 -7
- package/src/modules/base-achievements/base-achievements.module.ts +7 -5
- package/src/modules/confirmation-message-manager/confirmation-message-manager.constants.ts +3 -0
- package/src/modules/confirmation-message-manager/confirmation-message-manager.interfaces.ts +20 -0
- package/src/modules/confirmation-message-manager/confirmation-message-manager.module.ts +77 -0
- package/src/modules/confirmation-message-manager/confirmation-message-manager.service.ts +91 -0
- package/src/modules/event-bus/events-bus.module.ts +3 -0
- package/src/modules/event-bus/events-bus.player-ws-message.subscribe.service.ts +30 -0
- package/src/modules/event-bus/index.ts +1 -0
- package/src/modules/events/events.gateway.ts +13 -1
- package/src/modules/index.ts +1 -0
- package/src/modules/main/main.module.ts +1 -1
- package/src/modules/main/main.service.ts +1 -1
- package/src/modules/many-tables-tournament/many-tables-tournament.module.ts +1 -0
- package/src/modules/menu/menu-screen.view.ts +1 -1
- package/src/modules/menu/menu.service.ts +5 -1
- package/src/modules/one-table-tournament/one-table-tournament.module.ts +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jp.ms.common.modules",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.42",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"@nestjs/mongoose": "11.0.4",
|
|
14
14
|
"@nestjs/websockets": "11.1.9",
|
|
15
15
|
"dayjs": "1.11.18",
|
|
16
|
-
"jp.common.models": "1.1.
|
|
17
|
-
"jp.common.utils": "1.0.
|
|
18
|
-
"jp.db.schemas": "2.2.
|
|
19
|
-
"jp.ms.common.engine": "3.0.
|
|
16
|
+
"jp.common.models": "1.1.45",
|
|
17
|
+
"jp.common.utils": "1.0.6",
|
|
18
|
+
"jp.db.schemas": "2.2.14",
|
|
19
|
+
"jp.ms.common.engine": "3.0.25",
|
|
20
20
|
"mongoose": "9.1.5",
|
|
21
21
|
"nestjs-i18n": "10.5.1",
|
|
22
22
|
"node-schedule": "2.1.1",
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
+
import { Expose } from 'class-transformer';
|
|
3
|
+
import { IsString } from 'class-validator';
|
|
4
|
+
import { IAppTableBidsPanelItem } from 'jp.common.models';
|
|
5
|
+
|
|
6
|
+
export class BidsPanelItemDto implements IAppTableBidsPanelItem {
|
|
7
|
+
@ApiProperty({
|
|
8
|
+
description: 'key',
|
|
9
|
+
required: true,
|
|
10
|
+
type: String,
|
|
11
|
+
})
|
|
12
|
+
@Expose()
|
|
13
|
+
@IsString()
|
|
14
|
+
key: string;
|
|
15
|
+
|
|
16
|
+
@ApiProperty({
|
|
17
|
+
description: 'value',
|
|
18
|
+
required: true,
|
|
19
|
+
type: String,
|
|
20
|
+
})
|
|
21
|
+
@Expose()
|
|
22
|
+
@IsString()
|
|
23
|
+
value: string;
|
|
24
|
+
|
|
25
|
+
@ApiProperty({
|
|
26
|
+
description: 'Title',
|
|
27
|
+
required: true,
|
|
28
|
+
type: String,
|
|
29
|
+
})
|
|
30
|
+
@Expose()
|
|
31
|
+
@IsString()
|
|
32
|
+
title: string;
|
|
33
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Expose, Type } from 'class-transformer';
|
|
2
|
+
import { IsArray, IsBoolean, IsString, ValidateNested } from 'class-validator';
|
|
3
|
+
import { IAppTableBidsPanel } from 'jp.common.models';
|
|
4
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
5
|
+
|
|
6
|
+
import { BidsPanelItemDto } from './bids-panel-item.dto';
|
|
7
|
+
|
|
8
|
+
export class BidsPanelDto implements IAppTableBidsPanel {
|
|
9
|
+
@ApiProperty({
|
|
10
|
+
description: 'description',
|
|
11
|
+
required: true,
|
|
12
|
+
type: String,
|
|
13
|
+
})
|
|
14
|
+
@Expose()
|
|
15
|
+
@IsString()
|
|
16
|
+
description: string;
|
|
17
|
+
|
|
18
|
+
@ApiProperty({
|
|
19
|
+
description: 'isOpen',
|
|
20
|
+
required: true,
|
|
21
|
+
type: Boolean,
|
|
22
|
+
})
|
|
23
|
+
@Expose()
|
|
24
|
+
@IsBoolean()
|
|
25
|
+
isOpen: boolean;
|
|
26
|
+
|
|
27
|
+
@IsArray()
|
|
28
|
+
@ValidateNested({ each: true })
|
|
29
|
+
@Type(() => BidsPanelItemDto)
|
|
30
|
+
@Expose()
|
|
31
|
+
bids: Array<BidsPanelItemDto>;
|
|
32
|
+
}
|
|
@@ -11,3 +11,5 @@ export { MovesPanelDto } from './moves-panel.dto';
|
|
|
11
11
|
export { PlayerDto } from './player.dto';
|
|
12
12
|
export { SummaryDto } from './summary.dto';
|
|
13
13
|
export { SummaryItemDto } from './summary-item.dto';
|
|
14
|
+
export { BidsPanelDto } from './bids-panel.dto';
|
|
15
|
+
export { BidsPanelItemDto } from './bids-panel-item.dto';
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
CardsSlotsDto,
|
|
10
10
|
MovesPanelDto,
|
|
11
11
|
SummaryDto,
|
|
12
|
+
BidsPanelDto,
|
|
12
13
|
} from '../../app-table';
|
|
13
14
|
|
|
14
15
|
import { PokerPlayerDto } from './poker-player.dto';
|
|
@@ -68,6 +69,10 @@ export class PokerTableDto implements IPokerTable {
|
|
|
68
69
|
@Expose()
|
|
69
70
|
movesPanel: MovesPanelDto;
|
|
70
71
|
|
|
72
|
+
@Type(() => BidsPanelDto)
|
|
73
|
+
@Expose()
|
|
74
|
+
bidsPanel: BidsPanelDto;
|
|
75
|
+
|
|
71
76
|
constructor(entity: IPokerTable) {
|
|
72
77
|
return plainToInstance(PokerTableDto, entity, {
|
|
73
78
|
excludeExtraneousValues: true,
|
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
} from '@nestjs/common';
|
|
8
8
|
import schedule, { Job } from 'node-schedule';
|
|
9
9
|
|
|
10
|
+
import { JpLoggerService } from '../logger';
|
|
11
|
+
|
|
10
12
|
import { AntiFreezeSystemService } from './anti-freeze-system.service';
|
|
11
13
|
import { ANTI_FREEZE_SYSTEM_OPTIONS } from './anti-freeze-system.constants';
|
|
12
14
|
import {
|
|
@@ -25,6 +27,7 @@ export class AntiFreezeSystemModule {
|
|
|
25
27
|
private readonly antiFreezeSystemService: AntiFreezeSystemService,
|
|
26
28
|
@Inject(ANTI_FREEZE_SYSTEM_OPTIONS)
|
|
27
29
|
private readonly options: AntiFreezeSystemFactoryOptions,
|
|
30
|
+
@Inject() private readonly logger: JpLoggerService,
|
|
28
31
|
) {}
|
|
29
32
|
|
|
30
33
|
static forRootAsync(options: AntiFreezeSystemOptions): DynamicModule {
|
|
@@ -43,12 +46,13 @@ export class AntiFreezeSystemModule {
|
|
|
43
46
|
|
|
44
47
|
onModuleInit() {
|
|
45
48
|
const antiFreezeSystemTime = this.options.antiFreezeSystemTime;
|
|
46
|
-
const antiFreezeSystemCheckCount = this.options.antiFreezeSystemCheckCount;
|
|
47
49
|
|
|
48
50
|
if (antiFreezeSystemTime) {
|
|
51
|
+
this.logger.log(`${AntiFreezeSystemModule.name}: scheduleJob`);
|
|
52
|
+
|
|
49
53
|
this.antiFreezeSystemJob = schedule.scheduleJob(
|
|
50
54
|
antiFreezeSystemTime,
|
|
51
|
-
() => this.antiFreezeSystemService.process(
|
|
55
|
+
() => this.antiFreezeSystemService.process(),
|
|
52
56
|
);
|
|
53
57
|
}
|
|
54
58
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
1
|
+
import { Inject, Injectable } from '@nestjs/common';
|
|
2
2
|
import {
|
|
3
3
|
GameRoom,
|
|
4
4
|
ManyTablesTournamentRoom,
|
|
@@ -9,6 +9,10 @@ import {
|
|
|
9
9
|
import { SimpleRoomsManagerService } from '../simple-rooms-manager/simple-rooms-manager.service';
|
|
10
10
|
import { OneTableTournamentRoomsManagerService } from '../one-table-tournament-rooms-manager/one-table-tournament-rooms-manager.service';
|
|
11
11
|
import { ManyTablesTournamentRoomsManagerService } from '../many-tables-tournament-rooms-manager/many-tables-tournament-rooms-manager.service';
|
|
12
|
+
import { JpLoggerService } from '../logger';
|
|
13
|
+
|
|
14
|
+
import { AntiFreezeSystemFactoryOptions } from './anti-freeze-system.interfaces';
|
|
15
|
+
import { ANTI_FREEZE_SYSTEM_OPTIONS } from './anti-freeze-system.constants';
|
|
12
16
|
|
|
13
17
|
export interface IRoomSetItem {
|
|
14
18
|
tableId: string;
|
|
@@ -25,13 +29,16 @@ export class AntiFreezeSystemService {
|
|
|
25
29
|
private readonly simpleRoomsManagerService: SimpleRoomsManagerService,
|
|
26
30
|
private readonly oneTableRoomsManagerService: OneTableTournamentRoomsManagerService,
|
|
27
31
|
private readonly manyTablesRoomsManagerService: ManyTablesTournamentRoomsManagerService,
|
|
32
|
+
@Inject() private readonly logger: JpLoggerService,
|
|
33
|
+
@Inject(ANTI_FREEZE_SYSTEM_OPTIONS)
|
|
34
|
+
private readonly options: AntiFreezeSystemFactoryOptions,
|
|
28
35
|
) {
|
|
29
36
|
this.prevSet = new Map<string, IRoomSetItem>();
|
|
30
37
|
}
|
|
31
38
|
|
|
32
|
-
process(
|
|
39
|
+
process() {
|
|
33
40
|
this.mergeSets();
|
|
34
|
-
this.clear(
|
|
41
|
+
this.clear();
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
private mergeSets() {
|
|
@@ -48,6 +55,10 @@ export class AntiFreezeSystemService {
|
|
|
48
55
|
...currentSetItem,
|
|
49
56
|
count: prevSetItem.count + 1,
|
|
50
57
|
});
|
|
58
|
+
|
|
59
|
+
this.logger.log(
|
|
60
|
+
`${AntiFreezeSystemService.name}: tableId: ${prevSetItem.tableId}, count: ${prevSetItem.count}`,
|
|
61
|
+
);
|
|
51
62
|
} else {
|
|
52
63
|
newSet.set(currentSetKey, currentSetItem);
|
|
53
64
|
}
|
|
@@ -79,20 +90,40 @@ export class AntiFreezeSystemService {
|
|
|
79
90
|
return newSet;
|
|
80
91
|
}
|
|
81
92
|
|
|
82
|
-
private clear(
|
|
93
|
+
private clear() {
|
|
83
94
|
this.prevSet.forEach((item) => {
|
|
84
|
-
if (item.count ===
|
|
95
|
+
if (item.count === this.options.antiFreezeSystemCheckCount) {
|
|
85
96
|
if (item.room instanceof OneTableTournamentRoom) {
|
|
97
|
+
this.logger.log(
|
|
98
|
+
`${AntiFreezeSystemService.name}: cancel tournamentId: ${item.room.getId()}`,
|
|
99
|
+
);
|
|
86
100
|
const room = this.oneTableRoomsManagerService.getRoomByTableId(
|
|
87
101
|
item.tableId,
|
|
88
102
|
);
|
|
89
|
-
room?.
|
|
103
|
+
room?.getTables().forEach((table) => {
|
|
104
|
+
table.getPlayers().forEach((player) => {
|
|
105
|
+
room?.handleLeaveTournament(player);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
room?.getRoomMaster<TournamentMaster>().onTournamentCancel();
|
|
90
109
|
} else if (item.room instanceof ManyTablesTournamentRoom) {
|
|
110
|
+
this.logger.log(
|
|
111
|
+
`${AntiFreezeSystemService.name}: cancel tournamentId: ${item.room.getId()}`,
|
|
112
|
+
);
|
|
91
113
|
const room = this.manyTablesRoomsManagerService.getRoomByTableId(
|
|
92
114
|
item.tableId,
|
|
93
115
|
);
|
|
94
|
-
room?.
|
|
116
|
+
room?.getTables().forEach((table) => {
|
|
117
|
+
table.getPlayers().forEach((player) => {
|
|
118
|
+
room?.handleLeaveTournament(player);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
room?.getRoomMaster<TournamentMaster>().onTournamentCancel();
|
|
95
122
|
} else {
|
|
123
|
+
this.logger.log(
|
|
124
|
+
`${AntiFreezeSystemService.name}: restart tableId: ${item.tableId}`,
|
|
125
|
+
);
|
|
126
|
+
|
|
96
127
|
this.simpleRoomsManagerService
|
|
97
128
|
.getRoomByTableId(item.tableId)
|
|
98
129
|
?.restartTable(item.tableId);
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
Won3ProfiAchievement,
|
|
34
34
|
WonOneTableTournament3TimesAchievement,
|
|
35
35
|
} from 'jp.ms.common.engine';
|
|
36
|
-
import { AppScreenIconEnum } from 'jp.common.models';
|
|
36
|
+
import { AppScreenIconEnum, LanguageTypeEnum } from 'jp.common.models';
|
|
37
37
|
|
|
38
38
|
import { EventsBusAppSubscribeService } from '../event-bus/events-bus.app.subscribe.service';
|
|
39
39
|
import { PlayersManagerService } from '../players-manager';
|
|
@@ -82,7 +82,7 @@ export abstract class BaseAchievementsModule {
|
|
|
82
82
|
const player = this.playersManager.getPlayerById(userId);
|
|
83
83
|
const foundUser = await this.usersRepository.findById(userId);
|
|
84
84
|
const allAchievements: Array<Achievement> =
|
|
85
|
-
await this.achievementRepository.findAchievements();
|
|
85
|
+
await this.achievementRepository.findAchievements(event.game);
|
|
86
86
|
const usersAchievements: Array<UsersAchievement> =
|
|
87
87
|
await this.usersAchievementRepository.findAchivementsByUserId(userId);
|
|
88
88
|
|
|
@@ -95,6 +95,7 @@ export abstract class BaseAchievementsModule {
|
|
|
95
95
|
player.sendMessage(
|
|
96
96
|
new SnackbarSendToPlayerWsEvent(
|
|
97
97
|
event.game,
|
|
98
|
+
player.id,
|
|
98
99
|
AppScreenIconEnum.ARROW_UPWARD,
|
|
99
100
|
'level up',
|
|
100
101
|
'buttonText',
|
|
@@ -303,7 +304,7 @@ export abstract class BaseAchievementsModule {
|
|
|
303
304
|
user.userId,
|
|
304
305
|
user.fullName,
|
|
305
306
|
foundAchievement.achievementId,
|
|
306
|
-
foundAchievement.title,
|
|
307
|
+
foundAchievement.title[LanguageTypeEnum.RU],
|
|
307
308
|
foundAchievement.code,
|
|
308
309
|
foundAchievement.prize,
|
|
309
310
|
'',
|
|
@@ -312,9 +313,10 @@ export abstract class BaseAchievementsModule {
|
|
|
312
313
|
player.sendMessage(
|
|
313
314
|
new SnackbarSendToPlayerWsEvent(
|
|
314
315
|
game,
|
|
316
|
+
player.id,
|
|
315
317
|
AppScreenIconEnum.EMOJI_EVENTS,
|
|
316
|
-
foundAchievement.title,
|
|
317
|
-
foundAchievement.description,
|
|
318
|
+
foundAchievement.title[player.language],
|
|
319
|
+
foundAchievement.description[player.language],
|
|
318
320
|
),
|
|
319
321
|
);
|
|
320
322
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ModuleMetadata } from '@nestjs/common';
|
|
2
|
+
import { Type } from '@nestjs/common/interfaces/type.interface';
|
|
3
|
+
import { DynamicModule } from '@nestjs/common/interfaces/modules/dynamic-module.interface';
|
|
4
|
+
import { ForwardReference } from '@nestjs/common/interfaces/modules/forward-reference.interface';
|
|
5
|
+
|
|
6
|
+
export interface ConfirmationMessageManagerOptions extends Pick<
|
|
7
|
+
ModuleMetadata,
|
|
8
|
+
'imports'
|
|
9
|
+
> {
|
|
10
|
+
imports?: Array<
|
|
11
|
+
Type<any> | DynamicModule | Promise<DynamicModule> | ForwardReference
|
|
12
|
+
>;
|
|
13
|
+
inject?: any[];
|
|
14
|
+
useFactory?: (...args: any[]) => ConfirmationMessageManagerFactoryOptions;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ConfirmationMessageManagerFactoryOptions {
|
|
18
|
+
confirmationMessageManagerTime: string;
|
|
19
|
+
confirmationMessageManagerAttemptCount: number;
|
|
20
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DynamicModule,
|
|
3
|
+
Global,
|
|
4
|
+
Inject,
|
|
5
|
+
Module,
|
|
6
|
+
Provider,
|
|
7
|
+
} from '@nestjs/common';
|
|
8
|
+
import schedule, { Job } from 'node-schedule';
|
|
9
|
+
import { BaseWsEvent } from 'jp.ms.common.engine';
|
|
10
|
+
|
|
11
|
+
import { JpLoggerService } from '../logger';
|
|
12
|
+
import { EventsBusPlayerWsMessageSubscribeService } from '../event-bus';
|
|
13
|
+
|
|
14
|
+
import { ConfirmationMessageManagerService } from './confirmation-message-manager.service';
|
|
15
|
+
import {
|
|
16
|
+
ConfirmationMessageManagerFactoryOptions,
|
|
17
|
+
ConfirmationMessageManagerOptions,
|
|
18
|
+
} from './confirmation-message-manager.interfaces';
|
|
19
|
+
import { CONFIRMATION_MESSAGE_MANAGER_OPTIONS } from './confirmation-message-manager.constants';
|
|
20
|
+
|
|
21
|
+
@Global()
|
|
22
|
+
@Module({
|
|
23
|
+
providers: [ConfirmationMessageManagerService],
|
|
24
|
+
exports: [ConfirmationMessageManagerService],
|
|
25
|
+
})
|
|
26
|
+
export class ConfirmationMessageManagerModule {
|
|
27
|
+
private confirmationMessageManagerJob: Job;
|
|
28
|
+
|
|
29
|
+
constructor(
|
|
30
|
+
private readonly confirmationMessageManagerService: ConfirmationMessageManagerService,
|
|
31
|
+
private readonly eventsBusPlayerWsMessageSubscribeService: EventsBusPlayerWsMessageSubscribeService,
|
|
32
|
+
@Inject(CONFIRMATION_MESSAGE_MANAGER_OPTIONS)
|
|
33
|
+
private readonly options: ConfirmationMessageManagerFactoryOptions,
|
|
34
|
+
@Inject() private readonly logger: JpLoggerService,
|
|
35
|
+
) {}
|
|
36
|
+
|
|
37
|
+
static forRootAsync(
|
|
38
|
+
options: ConfirmationMessageManagerOptions,
|
|
39
|
+
): DynamicModule {
|
|
40
|
+
return {
|
|
41
|
+
module: ConfirmationMessageManagerModule,
|
|
42
|
+
imports: options.imports ?? [],
|
|
43
|
+
providers: [
|
|
44
|
+
{
|
|
45
|
+
provide: CONFIRMATION_MESSAGE_MANAGER_OPTIONS,
|
|
46
|
+
useFactory: options.useFactory,
|
|
47
|
+
inject: options.inject || [],
|
|
48
|
+
} as Provider,
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
onModuleInit() {
|
|
54
|
+
this.eventsBusPlayerWsMessageSubscribeService.subscribeOnSendMessage(
|
|
55
|
+
(wsEvent: BaseWsEvent) => {
|
|
56
|
+
this.confirmationMessageManagerService.addToQueue(wsEvent);
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
this.eventsBusPlayerWsMessageSubscribeService.subscribeOnGotMessageFromClient(
|
|
61
|
+
(wsEvent: BaseWsEvent) => {
|
|
62
|
+
this.confirmationMessageManagerService.removeFromQueue(wsEvent.key);
|
|
63
|
+
},
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const confirmationMessageManagerTime =
|
|
67
|
+
this.options.confirmationMessageManagerTime;
|
|
68
|
+
|
|
69
|
+
if (confirmationMessageManagerTime) {
|
|
70
|
+
this.logger.log(`${ConfirmationMessageManagerModule.name}: scheduleJob`);
|
|
71
|
+
this.confirmationMessageManagerJob = schedule.scheduleJob(
|
|
72
|
+
confirmationMessageManagerTime,
|
|
73
|
+
() => this.confirmationMessageManagerService.process(),
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Inject, Injectable } from '@nestjs/common';
|
|
2
|
+
import { BaseWsEvent } from 'jp.ms.common.engine';
|
|
3
|
+
|
|
4
|
+
import { PlayersManagerService } from '../players-manager';
|
|
5
|
+
import { JpLoggerService } from '../logger';
|
|
6
|
+
|
|
7
|
+
import { CONFIRMATION_MESSAGE_MANAGER_OPTIONS } from './confirmation-message-manager.constants';
|
|
8
|
+
import { ConfirmationMessageManagerFactoryOptions } from './confirmation-message-manager.interfaces';
|
|
9
|
+
|
|
10
|
+
interface IGameMessageConfirmationManagerMessage {
|
|
11
|
+
event: BaseWsEvent;
|
|
12
|
+
repeatCount: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@Injectable()
|
|
16
|
+
export class ConfirmationMessageManagerService {
|
|
17
|
+
private queue: Map<string, IGameMessageConfirmationManagerMessage>;
|
|
18
|
+
private jobId: NodeJS.Timeout | null = null;
|
|
19
|
+
|
|
20
|
+
constructor(
|
|
21
|
+
private readonly playersManagerService: PlayersManagerService,
|
|
22
|
+
@Inject(CONFIRMATION_MESSAGE_MANAGER_OPTIONS)
|
|
23
|
+
private readonly options: ConfirmationMessageManagerFactoryOptions,
|
|
24
|
+
@Inject() private readonly logger: JpLoggerService,
|
|
25
|
+
) {
|
|
26
|
+
this.queue = new Map<string, IGameMessageConfirmationManagerMessage>();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getByKey(key: string) {
|
|
30
|
+
this.queue.get(key);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
addToQueue(message: BaseWsEvent): void {
|
|
34
|
+
this.logger.log(
|
|
35
|
+
`${ConfirmationMessageManagerService.name}: add to queue ws message key: ${message.key}, type: ${message.type}`,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const foundMessage = this.queue.get(message.key);
|
|
39
|
+
|
|
40
|
+
if (foundMessage) {
|
|
41
|
+
foundMessage.repeatCount += 1;
|
|
42
|
+
} else {
|
|
43
|
+
this.queue.set(message.key, {
|
|
44
|
+
event: message,
|
|
45
|
+
repeatCount: 0,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
removeFromQueue(key: string): void {
|
|
51
|
+
this.logger.log(
|
|
52
|
+
`${ConfirmationMessageManagerService.name}: remove from queue ws message key: ${key}`,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
this.queue.delete(key);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
process() {
|
|
59
|
+
this.clearQueue();
|
|
60
|
+
this.repeatSendingMessages();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private isExpired(message: IGameMessageConfirmationManagerMessage): boolean {
|
|
64
|
+
return (
|
|
65
|
+
message.repeatCount >= this.options.confirmationMessageManagerAttemptCount
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private clearQueue(): void {
|
|
70
|
+
for (const [key, message] of this.queue) {
|
|
71
|
+
if (this.isExpired(message)) {
|
|
72
|
+
this.logger.log(
|
|
73
|
+
`${ConfirmationMessageManagerService.name}: clear expired ws message key: ${message.event.key}, type: ${message.event.type}`,
|
|
74
|
+
);
|
|
75
|
+
this.queue.delete(key);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private repeatSendingMessages(): void {
|
|
81
|
+
for (const [, message] of this.queue) {
|
|
82
|
+
const foundPlayer = this.playersManagerService.getPlayerById(
|
|
83
|
+
message.event.playerId,
|
|
84
|
+
);
|
|
85
|
+
this.logger.log(
|
|
86
|
+
`${ConfirmationMessageManagerService.name}: repeat ws message key: ${message.event.key}, type: ${message.event.type}, repeatCount: ${message.repeatCount}`,
|
|
87
|
+
);
|
|
88
|
+
foundPlayer?.sendMessage(message.event);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -4,6 +4,7 @@ import { EventsBusMainTablesSubscribeService } from './events-bus.main-tables.su
|
|
|
4
4
|
import { EventsBusOneTableTournamentSubscribeService } from './events-bus.one-table-tournament.subscribe.service';
|
|
5
5
|
import { EventsBusManyTablesTournamentSubscribeService } from './events-bus.many-tables-tournament.subscribe.service';
|
|
6
6
|
import { EventsBusAppSubscribeService } from './events-bus.app.subscribe.service';
|
|
7
|
+
import { EventsBusPlayerWsMessageSubscribeService } from './events-bus.player-ws-message.subscribe.service';
|
|
7
8
|
|
|
8
9
|
@Global()
|
|
9
10
|
@Module({
|
|
@@ -12,12 +13,14 @@ import { EventsBusAppSubscribeService } from './events-bus.app.subscribe.service
|
|
|
12
13
|
EventsBusOneTableTournamentSubscribeService,
|
|
13
14
|
EventsBusManyTablesTournamentSubscribeService,
|
|
14
15
|
EventsBusAppSubscribeService,
|
|
16
|
+
EventsBusPlayerWsMessageSubscribeService,
|
|
15
17
|
],
|
|
16
18
|
exports: [
|
|
17
19
|
EventsBusMainTablesSubscribeService,
|
|
18
20
|
EventsBusOneTableTournamentSubscribeService,
|
|
19
21
|
EventsBusManyTablesTournamentSubscribeService,
|
|
20
22
|
EventsBusAppSubscribeService,
|
|
23
|
+
EventsBusPlayerWsMessageSubscribeService,
|
|
21
24
|
],
|
|
22
25
|
})
|
|
23
26
|
export class EventsBusModule {}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BaseWsEvent } from 'jp.ms.common.engine';
|
|
2
|
+
import { Subject } from 'rxjs';
|
|
3
|
+
|
|
4
|
+
export class EventsBusPlayerWsMessageSubscribeService {
|
|
5
|
+
private readonly subjectSendMessage: Subject<BaseWsEvent>;
|
|
6
|
+
private readonly subjectGotMessage: Subject<BaseWsEvent>;
|
|
7
|
+
|
|
8
|
+
constructor() {
|
|
9
|
+
this.subjectSendMessage = new Subject<BaseWsEvent>();
|
|
10
|
+
this.subjectGotMessage = new Subject<BaseWsEvent>();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
pushSendMessage(event: BaseWsEvent) {
|
|
14
|
+
this.subjectSendMessage.next(event);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
pushGotMessage(event: BaseWsEvent) {
|
|
18
|
+
this.subjectGotMessage.next(event);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
subscribeOnSendMessage(onHandleWsEvent: (event: BaseWsEvent) => void) {
|
|
22
|
+
this.subjectSendMessage.subscribe(onHandleWsEvent);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
subscribeOnGotMessageFromClient(
|
|
26
|
+
onHandleWsEvent: (event: BaseWsEvent) => void,
|
|
27
|
+
) {
|
|
28
|
+
this.subjectGotMessage.subscribe(onHandleWsEvent);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -3,3 +3,4 @@ export { EventsBusMainTablesSubscribeService } from './events-bus.main-tables.su
|
|
|
3
3
|
export { EventsBusOneTableTournamentSubscribeService } from './events-bus.one-table-tournament.subscribe.service';
|
|
4
4
|
export { EventsBusManyTablesTournamentSubscribeService } from './events-bus.many-tables-tournament.subscribe.service';
|
|
5
5
|
export { EventsBusAppSubscribeService } from './events-bus.app.subscribe.service';
|
|
6
|
+
export { EventsBusPlayerWsMessageSubscribeService } from './events-bus.player-ws-message.subscribe.service';
|
|
@@ -7,8 +7,10 @@ import {
|
|
|
7
7
|
import { Server, Socket } from 'socket.io';
|
|
8
8
|
import { UsersRepository } from 'jp.db.schemas';
|
|
9
9
|
import { Inject } from '@nestjs/common';
|
|
10
|
+
import { BaseWsEvent } from 'jp.ms.common.engine';
|
|
10
11
|
|
|
11
12
|
import { PlayersManagerService } from '../players-manager/players-manager.service';
|
|
13
|
+
import { EventsBusPlayerWsMessageSubscribeService } from '../event-bus';
|
|
12
14
|
|
|
13
15
|
import { EVENTS_OPTIONS } from './events.constants';
|
|
14
16
|
import { EventsFactoryOptions } from './events.interfaces';
|
|
@@ -23,6 +25,7 @@ export class EventsGateway
|
|
|
23
25
|
constructor(
|
|
24
26
|
private readonly playersManager: PlayersManagerService,
|
|
25
27
|
private readonly usersRepository: UsersRepository,
|
|
28
|
+
private readonly eventsBusPlayerWsMessageSubscribeService: EventsBusPlayerWsMessageSubscribeService,
|
|
26
29
|
@Inject(EVENTS_OPTIONS) private readonly options: EventsFactoryOptions,
|
|
27
30
|
) {}
|
|
28
31
|
|
|
@@ -43,6 +46,8 @@ export class EventsGateway
|
|
|
43
46
|
experience: user.experience,
|
|
44
47
|
level: user.level,
|
|
45
48
|
language: user.normalizedLang,
|
|
49
|
+
onSendWsMessage: this.handleSendWsMessage,
|
|
50
|
+
onGotWsMessageClientResponse: this.handleGotWsMessageClientResponse,
|
|
46
51
|
});
|
|
47
52
|
this.playersManager.addPlayer(player);
|
|
48
53
|
player.connections.addConnection(client);
|
|
@@ -56,7 +61,6 @@ export class EventsGateway
|
|
|
56
61
|
|
|
57
62
|
if (connectedPlayer) {
|
|
58
63
|
connectedPlayer.disconnect();
|
|
59
|
-
|
|
60
64
|
if (
|
|
61
65
|
!connectedPlayer.isPlayer() &&
|
|
62
66
|
!connectedPlayer.isTableQueuer() &&
|
|
@@ -67,4 +71,12 @@ export class EventsGateway
|
|
|
67
71
|
}
|
|
68
72
|
}
|
|
69
73
|
}
|
|
74
|
+
|
|
75
|
+
handleSendWsMessage = (wsEvent: BaseWsEvent) => {
|
|
76
|
+
this.eventsBusPlayerWsMessageSubscribeService.pushSendMessage(wsEvent);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
handleGotWsMessageClientResponse = (wsEvent: BaseWsEvent) => {
|
|
80
|
+
this.eventsBusPlayerWsMessageSubscribeService.pushGotMessage(wsEvent);
|
|
81
|
+
};
|
|
70
82
|
}
|
package/src/modules/index.ts
CHANGED
|
@@ -25,3 +25,4 @@ export {
|
|
|
25
25
|
EventsBusMainTablesSubscribeService,
|
|
26
26
|
} from './event-bus';
|
|
27
27
|
export { BaseAchievementsModule } from './base-achievements/base-achievements.module';
|
|
28
|
+
export { ConfirmationMessageManagerModule } from './confirmation-message-manager/confirmation-message-manager.module';
|
|
@@ -126,7 +126,7 @@ export class MainService {
|
|
|
126
126
|
dayjs(last7logins[0].date).isToday() &&
|
|
127
127
|
last7logins[0].count === 1
|
|
128
128
|
) {
|
|
129
|
-
redirectUrl = AppScreenRoutesEnum.
|
|
129
|
+
redirectUrl = AppScreenRoutesEnum.DAILY_BONUS;
|
|
130
130
|
} else if (dayjs(foundUser.premiumExpired).isToday()) {
|
|
131
131
|
redirectUrl = AppScreenRoutesEnum.PREMIUM;
|
|
132
132
|
}
|
|
@@ -55,7 +55,7 @@ export class MenuScreenView extends UniversalScreenView {
|
|
|
55
55
|
'banner',
|
|
56
56
|
new BannerSectionListItemComponent(
|
|
57
57
|
this.banner.bannerId,
|
|
58
|
-
this.banner.
|
|
58
|
+
this.getDbResource(this.banner.title),
|
|
59
59
|
this.localeService.t('common.menu.header.title', { lang: this.lang }),
|
|
60
60
|
new UrlImageComponent(this.banner.image),
|
|
61
61
|
this.banner.link,
|
|
@@ -17,7 +17,11 @@ export class MenuService {
|
|
|
17
17
|
) {}
|
|
18
18
|
|
|
19
19
|
async getScreen(headers: IAppHeaders): Promise<BaseAppScreenDto> {
|
|
20
|
-
const menuItems =
|
|
20
|
+
const menuItems =
|
|
21
|
+
(await this.menuRepository.findMenus(
|
|
22
|
+
headers.client_game,
|
|
23
|
+
headers.client_channel,
|
|
24
|
+
)) ?? [];
|
|
21
25
|
const enabledBanner = await this.bannersRepository.findEnabledBanner(
|
|
22
26
|
headers.client_game,
|
|
23
27
|
headers.client_channel,
|
|
@@ -69,7 +69,11 @@ export class OneTableTournamentModule {
|
|
|
69
69
|
subscriber.id,
|
|
70
70
|
);
|
|
71
71
|
subscriber.sendMessage(
|
|
72
|
-
new OneTableTournamentUpdateStatusWsEvent(
|
|
72
|
+
new OneTableTournamentUpdateStatusWsEvent(
|
|
73
|
+
event.game,
|
|
74
|
+
subscriber.id,
|
|
75
|
+
screen.screen,
|
|
76
|
+
),
|
|
73
77
|
);
|
|
74
78
|
});
|
|
75
79
|
};
|