Server/project/src/callbacks/MatchCallbacks.ts

215 lines
8.7 KiB
TypeScript
Raw Normal View History

2023-03-03 16:23:46 +01:00
import { inject, injectable } from "tsyringe";
import { MatchController } from "@spt-aki/controllers/MatchController";
import { IEmptyRequestData } from "@spt-aki/models/eft/common/IEmptyRequestData";
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
import { INullResponseData } from "@spt-aki/models/eft/httpResponse/INullResponseData";
import { IAcceptGroupInviteRequest } from "@spt-aki/models/eft/match/IAcceptGroupInviteRequest";
import { IAcceptGroupInviteResponse } from "@spt-aki/models/eft/match/IAcceptGroupInviteResponse";
import { ICancelGroupInviteRequest } from "@spt-aki/models/eft/match/ICancelGroupInviteRequest";
import { ICreateGroupRequestData } from "@spt-aki/models/eft/match/ICreateGroupRequestData";
import { IEndOfflineRaidRequestData } from "@spt-aki/models/eft/match/IEndOfflineRaidRequestData";
import { IGetGroupStatusRequestData } from "@spt-aki/models/eft/match/IGetGroupStatusRequestData";
2023-12-20 01:17:27 +01:00
import { IGetGroupStatusResponse } from "@spt-aki/models/eft/match/IGetGroupStatusResponse";
import { IGetProfileRequestData } from "@spt-aki/models/eft/match/IGetProfileRequestData";
import { IGetRaidConfigurationRequestData } from "@spt-aki/models/eft/match/IGetRaidConfigurationRequestData";
import { IJoinMatchRequestData } from "@spt-aki/models/eft/match/IJoinMatchRequestData";
import { IJoinMatchResult } from "@spt-aki/models/eft/match/IJoinMatchResult";
import { IPutMetricsRequestData } from "@spt-aki/models/eft/match/IPutMetricsRequestData";
import { IRemovePlayerFromGroupRequest } from "@spt-aki/models/eft/match/IRemovePlayerFromGroupRequest";
import { ISendGroupInviteRequest } from "@spt-aki/models/eft/match/ISendGroupInviteRequest";
import { ITransferGroupRequest } from "@spt-aki/models/eft/match/ITransferGroupRequest";
import { IUpdatePingRequestData } from "@spt-aki/models/eft/match/IUpdatePingRequestData";
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil";
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
2023-03-03 16:23:46 +01:00
@injectable()
export class MatchCallbacks
{
constructor(
@inject("HttpResponseUtil") protected httpResponse: HttpResponseUtil,
@inject("JsonUtil") protected jsonUtil: JsonUtil,
@inject("MatchController") protected matchController: MatchController,
@inject("DatabaseServer") protected databaseServer: DatabaseServer,
2023-03-03 16:23:46 +01:00
)
{}
2023-03-03 16:23:46 +01:00
2023-07-15 15:49:25 +02:00
/** Handle client/match/updatePing */
2023-03-03 16:23:46 +01:00
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public updatePing(url: string, info: IUpdatePingRequestData, sessionID: string): INullResponseData
{
return this.httpResponse.nullResponse();
}
// Handle client/match/exit
2023-03-03 16:23:46 +01:00
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public exitMatch(url: string, info: IEmptyRequestData, sessionID: string): INullResponseData
{
return this.httpResponse.nullResponse();
}
2023-07-15 15:49:25 +02:00
/** Handle client/match/group/exit_from_menu */
2023-03-03 16:23:46 +01:00
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public exitToMenu(url: string, info: IEmptyRequestData, sessionID: string): INullResponseData
{
return this.httpResponse.nullResponse();
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public startGroupSearch(url: string, info: IEmptyRequestData, sessionID: string): INullResponseData
{
return this.httpResponse.nullResponse();
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public stopGroupSearch(url: string, info: IEmptyRequestData, sessionID: string): INullResponseData
{
return this.httpResponse.nullResponse();
}
2023-07-15 15:49:25 +02:00
/** Handle client/match/group/invite/send */
2023-03-03 16:23:46 +01:00
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public sendGroupInvite(url: string, info: ISendGroupInviteRequest, sessionID: string): IGetBodyResponseData<string>
2023-03-03 16:23:46 +01:00
{
return this.httpResponse.getBody("2427943f23698ay9f2863735");
2023-03-03 16:23:46 +01:00
}
/** Handle client/match/group/invite/accept */
2023-03-03 16:23:46 +01:00
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public acceptGroupInvite(
url: string,
info: IAcceptGroupInviteRequest,
sessionID: string,
): IGetBodyResponseData<IAcceptGroupInviteResponse[]>
2023-03-03 16:23:46 +01:00
{
const result = [];
result.push({});
return this.httpResponse.getBody(result);
2023-03-03 16:23:46 +01:00
}
/** Handle client/match/group/invite/cancel */
2023-03-03 16:23:46 +01:00
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public cancelGroupInvite(
url: string,
info: ICancelGroupInviteRequest,
sessionID: string,
): IGetBodyResponseData<boolean>
2023-03-03 16:23:46 +01:00
{
return this.httpResponse.getBody(true);
2023-03-03 16:23:46 +01:00
}
/** Handle client/match/group/transfer */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public transferGroup(url: string, info: ITransferGroupRequest, sessionID: string): IGetBodyResponseData<boolean>
{
return this.httpResponse.getBody(true);
}
2023-03-03 16:23:46 +01:00
2023-07-15 15:49:25 +02:00
/** Handle client/match/group/invite/cancel-all */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public cancelAllGroupInvite(url: string, info: any, sessionID: string): INullResponseData
{
return this.httpResponse.nullResponse();
}
/** @deprecated - not called on raid start/end or game start/exit */
2023-03-03 16:23:46 +01:00
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public putMetrics(url: string, info: IPutMetricsRequestData, sessionID: string): INullResponseData
{
return this.httpResponse.nullResponse();
}
// Handle client/match/available
2023-03-03 16:23:46 +01:00
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public serverAvailable(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<boolean>
2023-03-03 16:23:46 +01:00
{
const output = this.matchController.getEnabled();
return this.httpResponse.getBody(output);
}
2023-07-15 15:49:25 +02:00
/** Handle match/group/start_game */
public joinMatch(
url: string,
info: IJoinMatchRequestData,
sessionID: string,
): IGetBodyResponseData<IJoinMatchResult>
2023-03-03 16:23:46 +01:00
{
return this.httpResponse.getBody(this.matchController.joinMatch(info, sessionID));
}
2023-07-15 15:49:25 +02:00
/** Handle client/getMetricsConfig */
2023-03-03 16:23:46 +01:00
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public getMetrics(url: string, info: any, sessionID: string): IGetBodyResponseData<string>
{
return this.httpResponse.getBody(this.jsonUtil.serialize(this.databaseServer.getTables().match.metrics));
}
/**
* @deprecated - not called on raid start/end or game start/exit
2023-03-03 16:23:46 +01:00
* Handle client/match/group/status
* @returns
2023-03-03 16:23:46 +01:00
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public getGroupStatus(
url: string,
info: IGetGroupStatusRequestData,
sessionID: string,
): IGetBodyResponseData<IGetGroupStatusResponse>
2023-03-03 16:23:46 +01:00
{
return this.httpResponse.getBody(this.matchController.getGroupStatus(info));
}
2023-07-15 15:49:25 +02:00
/** Handle client/match/group/delete */
2023-03-03 16:23:46 +01:00
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public deleteGroup(url: string, info: any, sessionID: string): INullResponseData
{
this.matchController.deleteGroup(info);
return this.httpResponse.nullResponse();
}
// Handle client/match/group/leave
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public leaveGroup(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<boolean>
{
return this.httpResponse.getBody(true);
}
2023-07-15 15:49:25 +02:00
/** Handle client/match/group/player/remove */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public removePlayerFromGroup(url: string, info: IRemovePlayerFromGroupRequest, sessionID: string): INullResponseData
{
return this.httpResponse.nullResponse();
}
2023-07-15 15:49:25 +02:00
/** Handle client/match/offline/end */
2023-03-03 16:23:46 +01:00
public endOfflineRaid(url: string, info: IEndOfflineRaidRequestData, sessionID: string): INullResponseData
{
this.matchController.endOfflineRaid(info, sessionID);
return this.httpResponse.nullResponse();
}
2023-07-15 15:49:25 +02:00
/** Handle client/raid/configuration */
public getRaidConfiguration(
url: string,
info: IGetRaidConfigurationRequestData,
sessionID: string,
): INullResponseData
2023-03-03 16:23:46 +01:00
{
this.matchController.startOfflineRaid(info, sessionID);
return this.httpResponse.nullResponse();
}
2023-12-27 16:05:07 +01:00
/** Handle client/raid/configuration-by-profile */
public getConfigurationByProfile(
url: string,
info: IGetRaidConfigurationRequestData,
sessionID: string,
): INullResponseData
{
return this.httpResponse.nullResponse();
}
2023-03-03 16:23:46 +01:00
}