require api version with server connection requests

This commit is contained in:
ppc
2024-09-03 14:07:04 +01:00
parent e0a0002ca1
commit fdfbe73bb2
+16 -7
View File
@@ -7,22 +7,31 @@ export interface AMCardInRequest {
cardId: string;
}
export interface AMServerInfoResponse {
serverAddress: string;
serverName: string;
/**
* Information needed to perform a request against an AMNet server
*/
export interface AMServerConnectionInfo {
apiVersion: number;
gameId: string;
serverAddress: string;
}
/**
* Received metadata from an AMNet server
*/
export interface AMServerInfoResponse extends AMServerConnectionInfo {
serverName: string;
gameId?: string | null | undefined;
}
/**
* Performs the card-in request to the specified server
* @param serverAddress The origin address of the server to perform the request against
* @param server The server to perform the request against
* @param request The card-in request to send
* @param signal The abort signal to use for the request
*/
export async function performCardIn(serverAddress: string, request: AMCardInRequest, signal: AbortSignal) {
export async function performCardIn(server: AMServerConnectionInfo, request: AMCardInRequest, signal: AbortSignal) {
try {
const response = await fetch(`${new URL(serverAddress).origin}/amnet/signin`, {
const response = await fetch(`${new URL(server.serverAddress).origin}/amnet/signin`, {
method: "POST",
headers: {
"Content-Type": "application/json"