mirror of
https://gitea.tendokyu.moe/ppc/amnet.git
synced 2026-09-25 07:38:17 +03:00
require api version with server connection requests
This commit is contained in:
+16
-7
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user