Skip to content

Commit

Permalink
feat: read devserver argument
Browse files Browse the repository at this point in the history
  • Loading branch information
KotRikD committed Dec 7, 2024
1 parent e002e0b commit 149dbec
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/tosu/src/api/types/v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type ApiAnswerPrecise = TosuPreciseAnswer | { error?: string };

export interface TosuAPi {
client: string;
serverEndpoint: string;
state: NumberName;
session: Session;
settings: Settings;
Expand Down
1 change: 1 addition & 0 deletions packages/tosu/src/api/utils/buildResultV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export const buildResult = (instanceManager: InstanceManager): ApiAnswer => {

return {
client: ClientType[osuInstance.client],
serverEndpoint: osuInstance.customServerEndpoint ?? 'ppy.sh',
state: {
number: global.status,
name: GameState[global.status] || ''
Expand Down
5 changes: 5 additions & 0 deletions packages/tosu/src/instances/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export abstract class AbstractInstance {
abstract memory: AbstractMemory<Record<string, number>>;
abstract gameOverlayAllowed: boolean;
client: ClientType;
customServerEndpoint: string;

pid: number;
process: Process;
Expand Down Expand Up @@ -214,6 +215,10 @@ export abstract class AbstractInstance {
this.isTourneySpectator = newVal;
}

setCustomServerEndpoint(server: string) {
this.customServerEndpoint = server;
}

getState(instanceManager: InstanceManager) {
return buildResult(instanceManager);
}
Expand Down
4 changes: 4 additions & 0 deletions packages/tosu/src/instances/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export class InstanceManager {
osuInstance.setIsTourneySpectator(true);
}

if (args.devserver && args.devserver.length > 0) {
osuInstance.setCustomServerEndpoint(args.devserver);
}

osuInstance.emitter.on(
'onDestroy',
this.onProcessDestroy.bind(this)
Expand Down

0 comments on commit 149dbec

Please sign in to comment.