mirror of
https://gitea.tendokyu.moe/ppc/amnet.git
synced 2026-09-25 07:38:17 +03:00
send idm with card in requests
This commit is contained in:
@@ -147,10 +147,9 @@ export default function ServerCardIn({route, navigation}) {
|
||||
const cardInCallback = useCallback(() => {
|
||||
setCardInCompleted(false);
|
||||
|
||||
const cardId = selectedCard.physicalCardData && server.preferredCardIdFormat === "idm" ? icCard0008Number(selectedCard.physicalCardData.cardIDm) : selectedCard.code;
|
||||
const abortController = new AbortController();
|
||||
|
||||
performCardIn(server, {cardId}, abortController.signal).then(r => {
|
||||
performCardIn(server, {cardId: selectedCard.code, physicalCardIDm: selectedCard.physicalCardData?.cardIDm ?? undefined}, abortController.signal).then(r => {
|
||||
const now = new Date();
|
||||
realm.write(() => {
|
||||
server.lastUsed = now;
|
||||
@@ -178,10 +177,10 @@ export default function ServerCardIn({route, navigation}) {
|
||||
|
||||
setCardInCompleted(false);
|
||||
|
||||
const cardId = server.preferredCardIdFormat === "idm" || card.type !== ICType.Amusement ? icCard0008Number(card.idm) : card.accessCode;
|
||||
const cardId = card.type !== ICType.Amusement ? icCard0008Number(card.idm) : card.accessCode;
|
||||
const abortController = new AbortController();
|
||||
|
||||
performCardIn(server, {cardId}, abortController.signal).then(r => {
|
||||
performCardIn(server, {cardId, physicalCardIDm: card.idm}, abortController.signal).then(r => {
|
||||
setCardInCompleted(r);
|
||||
}).catch(() => {
|
||||
setCardInCompleted(false);
|
||||
|
||||
Vendored
+3
-5
@@ -8,6 +8,7 @@ declare const AMNET_API_VERSION = 1;
|
||||
declare const MIN_AMNET_API_VERSION = 1;
|
||||
interface AMCardInRequest {
|
||||
cardId: string;
|
||||
physicalCardIDm?: string;
|
||||
}
|
||||
/**
|
||||
* Server connection info (api version, address, etc.)
|
||||
@@ -30,13 +31,10 @@ interface AMServerInstanceMetrics {
|
||||
timeSinceLastPoll?: number;
|
||||
sessionUptime?: number;
|
||||
}
|
||||
interface AMServerPhysicalCardPreferences {
|
||||
preferredCardIdFormat?: "idm" | "access" | null;
|
||||
}
|
||||
/**
|
||||
* The response from an AMNet server's info endpoint
|
||||
*/
|
||||
type AMServerInfo = AMServerMetadata & AMServerConnectionInfo & AMServerInstanceMetrics & AMServerPhysicalCardPreferences;
|
||||
type AMServerInfo = AMServerMetadata & AMServerConnectionInfo & AMServerInstanceMetrics;
|
||||
/**
|
||||
* Performs the card-in request to the specified server
|
||||
* @param server The server to perform the request against
|
||||
@@ -65,4 +63,4 @@ declare function validateCardId(id: string): boolean;
|
||||
*/
|
||||
declare function getGameName(id: string): string | null;
|
||||
|
||||
export { type AMCardInRequest, AMNET_API_VERSION, type AMServerConnectionInfo, type AMServerInfo, type AMServerInstanceMetrics, type AMServerMetadata, type AMServerPhysicalCardPreferences, CARD_ID_REGEX, MIN_AMNET_API_VERSION, fetchServerInfo, generateCardNumber, getGameName, performCardIn, validateCardId };
|
||||
export { type AMCardInRequest, AMNET_API_VERSION, type AMServerConnectionInfo, type AMServerInfo, type AMServerInstanceMetrics, type AMServerMetadata, CARD_ID_REGEX, MIN_AMNET_API_VERSION, fetchServerInfo, generateCardNumber, getGameName, performCardIn, validateCardId };
|
||||
|
||||
Vendored
+3
-5
@@ -8,6 +8,7 @@ declare const AMNET_API_VERSION = 1;
|
||||
declare const MIN_AMNET_API_VERSION = 1;
|
||||
interface AMCardInRequest {
|
||||
cardId: string;
|
||||
physicalCardIDm?: string;
|
||||
}
|
||||
/**
|
||||
* Server connection info (api version, address, etc.)
|
||||
@@ -30,13 +31,10 @@ interface AMServerInstanceMetrics {
|
||||
timeSinceLastPoll?: number;
|
||||
sessionUptime?: number;
|
||||
}
|
||||
interface AMServerPhysicalCardPreferences {
|
||||
preferredCardIdFormat?: "idm" | "access" | null;
|
||||
}
|
||||
/**
|
||||
* The response from an AMNet server's info endpoint
|
||||
*/
|
||||
type AMServerInfo = AMServerMetadata & AMServerConnectionInfo & AMServerInstanceMetrics & AMServerPhysicalCardPreferences;
|
||||
type AMServerInfo = AMServerMetadata & AMServerConnectionInfo & AMServerInstanceMetrics;
|
||||
/**
|
||||
* Performs the card-in request to the specified server
|
||||
* @param server The server to perform the request against
|
||||
@@ -65,4 +63,4 @@ declare function validateCardId(id: string): boolean;
|
||||
*/
|
||||
declare function getGameName(id: string): string | null;
|
||||
|
||||
export { type AMCardInRequest, AMNET_API_VERSION, type AMServerConnectionInfo, type AMServerInfo, type AMServerInstanceMetrics, type AMServerMetadata, type AMServerPhysicalCardPreferences, CARD_ID_REGEX, MIN_AMNET_API_VERSION, fetchServerInfo, generateCardNumber, getGameName, performCardIn, validateCardId };
|
||||
export { type AMCardInRequest, AMNET_API_VERSION, type AMServerConnectionInfo, type AMServerInfo, type AMServerInstanceMetrics, type AMServerMetadata, CARD_ID_REGEX, MIN_AMNET_API_VERSION, fetchServerInfo, generateCardNumber, getGameName, performCardIn, validateCardId };
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -10,6 +10,7 @@ export const MIN_AMNET_API_VERSION = 1;
|
||||
|
||||
export interface AMCardInRequest {
|
||||
cardId: string;
|
||||
physicalCardIDm?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,14 +37,10 @@ export interface AMServerInstanceMetrics {
|
||||
sessionUptime?: number;
|
||||
}
|
||||
|
||||
export interface AMServerPhysicalCardPreferences {
|
||||
preferredCardIdFormat?: "idm" | "access" | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The response from an AMNet server's info endpoint
|
||||
*/
|
||||
export type AMServerInfo = AMServerMetadata & AMServerConnectionInfo & AMServerInstanceMetrics & AMServerPhysicalCardPreferences;
|
||||
export type AMServerInfo = AMServerMetadata & AMServerConnectionInfo & AMServerInstanceMetrics;
|
||||
|
||||
/**
|
||||
* Performs the card-in request to the specified server
|
||||
@@ -55,7 +52,7 @@ export async function performCardIn(server: AMServerConnectionInfo, request: AMC
|
||||
if (server.apiVersion < MIN_AMNET_API_VERSION || server.apiVersion > AMNET_API_VERSION) {
|
||||
throw new Error("Unsupported server API version");
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
const response = await fetch(`${new URL(server.serverAddress).origin}/amnet/signin`, {
|
||||
method: "POST",
|
||||
@@ -82,7 +79,7 @@ export async function fetchServerInfo(serverAddress: string, abort: AbortSignal)
|
||||
const response = await fetch(`${new URL(serverAddress).origin}/amnet/info`, {
|
||||
signal: abort
|
||||
});
|
||||
|
||||
|
||||
if (!response.ok) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user