From d35607068808dda685dabe35e9b673731f8a4a5b Mon Sep 17 00:00:00 2001 From: XDenizX Date: Tue, 12 Dec 2023 09:49:35 +0000 Subject: [PATCH] Added the display of the nickname of the connected player during logging. (!173) Co-authored-by: XDenizX Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/173 Co-authored-by: XDenizX Co-committed-by: XDenizX --- project/src/servers/WebSocketServer.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/project/src/servers/WebSocketServer.ts b/project/src/servers/WebSocketServer.ts index 19fa82eb..d2c82be3 100644 --- a/project/src/servers/WebSocketServer.ts +++ b/project/src/servers/WebSocketServer.ts @@ -11,6 +11,7 @@ import { ConfigServer } from "@spt-aki/servers/ConfigServer"; import { LocalisationService } from "@spt-aki/services/LocalisationService"; import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; +import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; @injectable() export class WebSocketServer @@ -22,6 +23,7 @@ export class WebSocketServer @inject("LocalisationService") protected localisationService: LocalisationService, @inject("JsonUtil") protected jsonUtil: JsonUtil, @inject("HttpServerHelper") protected httpServerHelper: HttpServerHelper, + @inject("ProfileHelper") protected profileHelper: ProfileHelper, ) { this.httpConfig = this.configServer.getConfig(ConfigTypes.HTTP); @@ -92,11 +94,13 @@ export class WebSocketServer // Strip request and break it into sections const splitUrl = req.url.substring(0, req.url.indexOf("?")).split("/"); const sessionID = splitUrl.pop(); + const playerProfile = this.profileHelper.getFullProfile(sessionID); + const playerInfoText = `${playerProfile.info.username} (${sessionID})`; - this.logger.info(this.localisationService.getText("websocket-player_connected", sessionID)); + this.logger.info(this.localisationService.getText("websocket-player_connected", playerInfoText)); const logger = this.logger; - const msgToLog = this.localisationService.getText("websocket-received_message", sessionID); + const msgToLog = this.localisationService.getText("websocket-received_message", playerInfoText); ws.on("message", function message(msg) { logger.info(`${msgToLog} ${msg}`);