feat : 보스 레이드 입장 메시지 기능 추가

This commit is contained in:
qornwh1
2026-03-16 17:55:08 +09:00
parent 943302c2f1
commit f6b378cad7
7 changed files with 312 additions and 14 deletions

View File

@@ -35,7 +35,7 @@ public class RestApi : Singleton<RestApi>
if (response.StatusCode == HttpStatusCode.Unauthorized)
{
Log.Warning("[RestApi] 토큰 인증 실패 (401)");
return null;
return "";
}
response.EnsureSuccessStatusCode();
@@ -56,7 +56,7 @@ public class RestApi : Singleton<RestApi>
}
}
return null;
return "";
}
private sealed class AuthVerifyResponse
@@ -68,4 +68,94 @@ public class RestApi : Singleton<RestApi>
set;
}
}
// 레이드 채널 접속 여부 체크
// 성공 시 sessionName 반환, 실패/거절 시 null 반환
public async Task<bool?> BossRaidAccesssAsync(List<string> userNames, int bossId)
{
string url = AppConfig.RestApi.BaseUrl + "/api/internal/bossraid/entry";
for (int attempt = 1; attempt <= MAX_RETRY; attempt++)
{
try
{
HttpResponseMessage response = await httpClient.PostAsJsonAsync(url, new { usernames = userNames, bossId });
// 401: API 키 인증 실패
if (response.StatusCode == HttpStatusCode.Unauthorized)
{
Log.Warning("[RestApi] 보스 레이드 접속 인증 실패 (401)");
return false;
}
// 400: 입장 조건 미충족 (레벨 부족, 이미 진행중 등)
if (response.StatusCode == HttpStatusCode.BadRequest)
{
Log.Warning("[RestApi] 보스 레이드 입장 거절 (400) BossId={BossId}", bossId);
return false;
}
response.EnsureSuccessStatusCode();
BossRaidAccessResponse? result = await response.Content.ReadFromJsonAsync<BossRaidAccessResponse>();
return result?.BossId > 0 ? true : false;
}
catch (Exception ex) when (attempt < MAX_RETRY)
{
Log.Warning("[RestApi] 보스 레이드 통신 실패 (시도 {Attempt}/{Max}): {Message}", attempt, MAX_RETRY, ex.Message);
await Task.Delay(RETRY_DELAY);
}
catch (Exception ex)
{
Log.Error("[RestApi] 보스 레이드 최종 통신 실패 ({Max}회 시도): {Message}", MAX_RETRY, ex.Message);
}
}
return false;
}
private sealed class BossRaidAccessResponse
{
[JsonPropertyName("roomId")]
public int RoomId
{
get;
set;
}
[JsonPropertyName("sessionName")]
public string? SessionName
{
get;
set;
}
[JsonPropertyName("bossId")]
public int BossId
{
get;
set;
}
[JsonPropertyName("players")]
public List<string> Players
{
get;
set;
} = new();
[JsonPropertyName("status")]
public string? Status
{
get;
set;
}
[JsonPropertyName("tokens")]
public Dictionary<string, string> Tokens
{
get;
set;
} = new();
}
}