Added the display of the nickname of the connected player during logging. (!173)

Co-authored-by: XDenizX <denizik1@mail.ru>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/173
Co-authored-by: XDenizX <xdenizx@noreply.dev.sp-tarkov.com>
Co-committed-by: XDenizX <xdenizx@noreply.dev.sp-tarkov.com>
This commit is contained in:
XDenizX 2023-12-12 09:49:35 +00:00 committed by chomp
parent 97643f6d70
commit d356070688

View File

@ -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}`);