diff --git a/src/components/list-contact/ListContactInfoPanel.tsx b/src/components/list-contact/ListContactInfoPanel.tsx index ed4e1fc..981b5ab 100644 --- a/src/components/list-contact/ListContactInfoPanel.tsx +++ b/src/components/list-contact/ListContactInfoPanel.tsx @@ -151,7 +151,15 @@ const ListContactInfoPanel = ({ return } - if (!telNum) return + if (!telNum.trim()) { + alert('전화번호가 없습니다.') + return + } + // CTI는 ANINumber가 비어 있으면 Default 발신번호로 건다고 하지만, 의도치 않은 번호로 나가지 않도록 막는다. + if (!callerTelNum?.trim()) { + alert('프로젝트에 발신 번호가 등록되지 않았습니다.') + return + } ctiClient.makeCall({ dialNumber: telNum, prjctIdx, sid, listHderId, aniNumber: callerTelNum ?? '' }) } diff --git a/src/const/ctiConst.ts b/src/const/ctiConst.ts index 4407f00..19dda20 100644 --- a/src/const/ctiConst.ts +++ b/src/const/ctiConst.ts @@ -17,3 +17,6 @@ export const CTI_STATE_TTL_MS = 2 * 60 * 60 * 1000; // 종료 신호를 놓친 것으로 보고 idle로 되돌린다. export const CTI_DIALING_TIMEOUT_MS = 30 * 1000; +// 처리하지 않는 오류(ZCommand에 Error 포함) alert를 같은 ZCommand에 대해 다시 띄우기까지의 최소 간격 +export const CTI_ERROR_ALERT_THROTTLE_MS = 10 * 1000; + diff --git a/src/lib/cti/ctiClient.ts b/src/lib/cti/ctiClient.ts index 37bea84..43e752c 100644 --- a/src/lib/cti/ctiClient.ts +++ b/src/lib/cti/ctiClient.ts @@ -4,6 +4,7 @@ import { HttpError } from "@kri/common/http"; import { CTI_AGENT_GROUP, CTI_DIALING_TIMEOUT_MS, + CTI_ERROR_ALERT_THROTTLE_MS, CTI_ON_CALL_STATUSES, CTI_STATE_TTL_MS, } from "@/const/ctiConst"; @@ -96,6 +97,7 @@ let hangupRequested = false; let callClosedReceived = false; let reconnectIntervalId: ReturnType | null = null; let dialingTimeoutId: ReturnType | null = null; +const lastErrorAlertAt = new Map(); const listeners = new Set<() => void>(); @@ -506,6 +508,16 @@ const saveCallHistory = (parsed: Record, phase: "start" | "clos }; +// 외주 문서에 오류 명세가 없어, 처리하지 않는 오류는 상태를 건드리지 않고 알리기만 한다. +// 재연결 루프 등으로 같은 오류가 반복될 수 있어 ZCommand별로 일정 간격 안의 중복 alert는 생략한다. +const alertUnhandledError = (zCommand: string) => { + const now = Date.now(); + const lastAt = lastErrorAlertAt.get(zCommand); + if (lastAt !== undefined && now - lastAt < CTI_ERROR_ALERT_THROTTLE_MS) return; + lastErrorAlertAt.set(zCommand, now); + alert(`${zCommand} 오류가 발생했습니다. 관리자에게 문의하세요.`); +}; + // WS 서버 -> 클라이언트로 오는 메시지는 ZCommand가 기준값이다. // 새로운 서버 이벤트에 대한 후속 조치가 필요하면 여기 case를 추가한다. const handleIncomingMessage = (raw: unknown) => { @@ -575,7 +587,23 @@ const handleIncomingMessage = (raw: unknown) => { } break; } + case "MakeCallError": { + console.warn("[CTI][TEMP_LOG] MakeCallError ->", parsed); // TEMP_CTI_LOG + // 오류 메시지에는 AgntSessionID가 없어 어떤 발신인지 대조할 수 없으므로, 받기 전(dialing) 상태일 때만 정리한다. + if (activeCall && activeCall.agentSessionId == null) { + clearDialingTimeout(); + activeCall = null; + persistCtiState(); + notify(); + } + alert("전화 연결에 실패했습니다."); + break; + } default: + console.warn("[CTI][TEMP_LOG] unhandled message ->", parsed.ZCommand, parsed); // TEMP_CTI_LOG + if (typeof parsed.ZCommand === "string" && parsed.ZCommand.includes("Error")) { + alertUnhandledError(parsed.ZCommand); + } break; } };