본문으로 건너뛰기

테이블 조회

리더보드 테이블 정보를 조회하는 API입니다.

URL 확인

이 API는 service-api.playnanoo.com 도메인을 사용합니다.

API 정보​

  • URL: https://service-api.playnanoo.com/leaderboard/v20240301/table/show
  • Method: PUT
  • 인증 필요: 예
DeviceInfo 상속

이 API의 Req 클래스는 DeviceInfo를 상속받습니다. DeviceInfo의 모든 속성이 자동으로 포함됩니다.

요청 파라미터​

파라미터타입필수설명
uidstring필수테이블 코드

응답 데이터​

Res 클래스​

필드타입설명
Rotationstring순환 방식
RotationCountint현재 시즌 번호
RotationTimeLeftint시즌 종료까지 남은 시간 (초)
RecordTypestring기록 타입
RecordSortTypestring정렬 타입
TotalIdsdouble총 기록 수

Unity C# 구현​

BaseResponse 클래스​

모든 API 응답의 기본 클래스입니다.

public class BaseResponse
{
public string ErrorCode;
public string Message;
public string WithdrawalKey;
public string BlockKey;
}

필드 설명:

  • ErrorCode: 에러 코드
  • Message: 에러 메시지
  • WithdrawalKey: 탈퇴 유예 상태인 경우 복구에 필요한 키 (탈퇴 유예 중인 계정만 제공)
  • BlockKey: 차단된 계정인 경우 제공되는 키 (차단된 계정만 제공)

테이블 조회 클래스​

using System;
using System.Collections;
using UnityEngine.Networking;

public class TableShow
{
static string path = "https://service-api.playnanoo.com/leaderboard/v20240301/table/show";

[Serializable]
public class Req : DeviceInfo
{
public string uid;

public IEnumerator Send(string table_code, Action<Res> onSuccess, Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(table_code)) this.uid = table_code;

yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}

[Serializable]
public class Res : BaseResponse
{
public string Rotation;
public int RotationCount;
public int RotationTimeLeft;
public string RecordType;
public string RecordSortType;
public double TotalIds;
}
}

사용 예제​

public void ShowLeaderboardTable()
{
TableShow.Req req = new TableShow.Req();

StartCoroutine(req.Send(
table_code: "my_leaderboard_table",
onSuccess: res =>
{
Debug.Log("테이블 조회 성공");
Debug.Log($"순환 방식: {res.Rotation}");
Debug.Log($"현재 시즌: {res.RotationCount}");
Debug.Log($"시즌 종료까지 남은 시간: {res.RotationTimeLeft}초");
Debug.Log($"기록 타입: {res.RecordType}");
Debug.Log($"정렬 타입: {res.RecordSortType}");
Debug.Log($"총 기록 수: {res.TotalIds}");

// 시즌 종료까지 남은 시간을 사용자에게 표시
TimeSpan timeLeft = TimeSpan.FromSeconds(res.RotationTimeLeft);
Debug.Log($"시즌 종료까지: {timeLeft.Days}일 {timeLeft.Hours}시간 {timeLeft.Minutes}분");
},
onError: error =>
{
Debug.LogError($"테이블 조회 실패: [{error.ErrorCode}] {error.Message}");
}
));
}
테이블 정보

이 API를 통해 리더보드의 현재 설정과 상태를 확인할 수 있습니다. 시즌이 곧 종료될 예정인지, 현재 몇 명의 플레이어가 참여하고 있는지 등의 정보를 얻을 수 있습니다.

시즌 타이머

RotationTimeLeft를 사용하여 시즌 종료 타이머를 UI에 표시할 수 있습니다. 이를 통해 플레이어들이 시즌이 언제 종료되는지 알 수 있습니다.