@game-vir/multiplayer
Version:
Client side definitions and types for @game-vir/multiplayer-server
190 lines (189 loc) • 10.5 kB
TypeScript
/**
* Shape definition for {@link MultiplayerClientRoom}.
*
* @category Internal
*/
export declare const multiplayerClientRoomShape: import("object-shape-tester").ShapeDefinition<{
roomName: string;
roomId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
clientCount: number;
hasRoomPassword: boolean;
}, false>;
/**
* Room stats presented to clients when they fetch the current list of rooms.
*
* @category Internal
*/
export type MultiplayerClientRoom = typeof multiplayerClientRoomShape.runtimeType;
/**
* Shape definition for {@link MultiplayerClientRooms}.
*
* @category Internal
*/
export declare const multiplayerClientRoomsShape: import("object-shape-tester").ShapeDefinition<import("object-shape-tester").ShapeIndexedKeys<[{
keys: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
values: import("object-shape-tester").ShapeDefinition<{
roomName: string;
roomId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
clientCount: number;
hasRoomPassword: boolean;
}, false>;
required: false;
}]>, false>;
/**
* A collection of {@link MultiplayerClientRoom} instances.
*
* @category Internal
*/
export type MultiplayerClientRooms = typeof multiplayerClientRoomsShape.runtimeType;
/**
* The output from {@link defineMultiplayerService}, regardless of what the passed-in `serviceOrigin`
* is.
*
* @category Internal
*/
export type MultiplayerService = ReturnType<typeof defineMultiplayerService>;
/**
* The default, or starting, port for the multiplayer service.
*
* @category Internal
*/
export declare const defaultMultiplayerServicePort = 3500;
/**
* The default multiplayer service origin.
*
* @category Internal
*/
export declare const defaultMultiplayerServiceOrigin: string;
/**
* The multiplayer service definition.
*
* @category Internal
*/
export declare function defineMultiplayerService(backendOrigin?: string): import("@rest-vir/define-service").ServiceDefinition<"multiplayer-service", {
'/': {
methods: {
GET: true;
};
requestDataShape: undefined;
responseDataShape: import("object-shape-tester").ShapeExact<readonly ["ok"]>;
requiredClientOrigin: {
anyOrigin: boolean;
};
};
'/health': {
methods: {
GET: true;
};
requestDataShape: undefined;
responseDataShape: import("object-shape-tester").ShapeExact<readonly ["ok"]>;
requiredClientOrigin: {
anyOrigin: boolean;
};
};
'/rooms': {
requestDataShape: undefined;
responseDataShape: import("object-shape-tester").ShapeDefinition<import("object-shape-tester").ShapeIndexedKeys<[{
keys: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
values: import("object-shape-tester").ShapeDefinition<{
roomName: string;
roomId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
clientCount: number;
hasRoomPassword: boolean;
}, false>;
required: false;
}]>, false>;
methods: {
GET: true;
};
searchParamsShape: {
gameId: import("object-shape-tester").ShapeTuple<[string]>;
};
};
}, {
'/connect': {
messageFromClientShape: import("object-shape-tester").ShapeOr<[import("object-shape-tester").ShapeDefinition<import("object-shape-tester").ShapeAnd<[import("object-shape-tester").ShapeDefinition<{
clientId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
roomId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
roomName: string;
}, false>, import("object-shape-tester").ShapeDefinition<{
messageId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
}, false>, {
type: import("object-shape-tester").ShapeExact<readonly [import("../index.js").MultiplayerWebSocketMessageType.Answer]>;
data: import("object-shape-tester").ShapeOr<[{
rejected: import("object-shape-tester").ShapeExact<readonly [true]>;
}, import("object-shape-tester").ShapeDefinition<{
type: import("object-shape-tester").ShapeExact<readonly [import("../index.js").MultiplayerWebSocketMessageType.Answer]>;
sdp: string;
}, false>]>;
}]>, false>, import("object-shape-tester").ShapeDefinition<import("object-shape-tester").ShapeAnd<[import("object-shape-tester").ShapeDefinition<import("object-shape-tester").ShapeAnd<[import("object-shape-tester").ShapeDefinition<{
clientId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
roomId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
roomName: string;
}, false>, import("object-shape-tester").ShapeDefinition<{
messageId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
}, false>, {
type: import("object-shape-tester").ShapeExact<readonly [import("../index.js").MultiplayerWebSocketMessageType.Offer]>;
data: import("object-shape-tester").ShapeDefinition<{
type: import("object-shape-tester").ShapeExact<readonly [import("../index.js").MultiplayerWebSocketMessageType.Offer]>;
sdp: string;
}, false>;
}]>, false>, import("object-shape-tester").ShapeDefinition<{
messageId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
}, false>, {
clientSecret: string;
roomPassword: string;
}]>, false>, import("object-shape-tester").ShapeDefinition<import("object-shape-tester").ShapeAnd<[import("object-shape-tester").ShapeDefinition<{
clientId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
roomId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
roomName: string;
}, false>, import("object-shape-tester").ShapeDefinition<{
messageId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
}, false>, {
type: import("object-shape-tester").ShapeExact<readonly [import("../index.js").MultiplayerWebSocketMessageType.HostPing]>;
clientSecret: string;
clientCount: number;
roomPassword: string;
}]>, false>]>;
messageFromHostShape: import("object-shape-tester").ShapeOr<[import("object-shape-tester").ShapeDefinition<import("object-shape-tester").ShapeAnd<[import("object-shape-tester").ShapeDefinition<{
clientId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
roomId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
roomName: string;
}, false>, import("object-shape-tester").ShapeDefinition<{
messageId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
}, false>, {
type: import("object-shape-tester").ShapeExact<readonly [import("../index.js").MultiplayerWebSocketMessageType.Answer]>;
data: import("object-shape-tester").ShapeOr<[{
rejected: import("object-shape-tester").ShapeExact<readonly [true]>;
}, import("object-shape-tester").ShapeDefinition<{
type: import("object-shape-tester").ShapeExact<readonly [import("../index.js").MultiplayerWebSocketMessageType.Answer]>;
sdp: string;
}, false>]>;
}]>, false>, import("object-shape-tester").ShapeDefinition<import("object-shape-tester").ShapeAnd<[import("object-shape-tester").ShapeDefinition<{
clientId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
roomId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
roomName: string;
}, false>, import("object-shape-tester").ShapeDefinition<{
messageId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
}, false>, {
type: import("object-shape-tester").ShapeExact<readonly [import("../index.js").MultiplayerWebSocketMessageType.Offer]>;
data: import("object-shape-tester").ShapeDefinition<{
type: import("object-shape-tester").ShapeExact<readonly [import("../index.js").MultiplayerWebSocketMessageType.Offer]>;
sdp: string;
}, false>;
}]>, false>, import("object-shape-tester").ShapeDefinition<import("object-shape-tester").ShapeAnd<[import("object-shape-tester").ShapeDefinition<{
messageId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
}, false>, {
type: import("object-shape-tester").ShapeExact<readonly [import("../index.js").MultiplayerWebSocketMessageType.OfferResult]>;
hostClientId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
}]>, false>, import("object-shape-tester").ShapeDefinition<import("object-shape-tester").ShapeAnd<[import("object-shape-tester").ShapeDefinition<{
messageId: import("object-shape-tester").CustomSpecifier<`${string}-${string}-${string}-${string}-${string}`>;
}, false>, {
type: import("object-shape-tester").ShapeExact<readonly [import("../index.js").MultiplayerWebSocketMessageType.Error]>;
errorMessage: string;
}]>, false>]>;
searchParamsShape: {
gameId: import("object-shape-tester").ShapeTuple<[string]>;
};
};
}>;